Results 1 to 16 of 16

Thread: copying vbcode from posts

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    copying vbcode from posts

    if you get annoyed at the line numbering in the vbcode boxes when copying to paste elsewhere

    vb Code:
    1. Sub Main()
    2. Dim myarr() As String
    3. myarr = Split(Clipboard.GetText, vbNewLine)
    4. For i = UBound(myarr) To 0 Step -1
    5.     If IsNumeric(myarr(i)) Then myarr(i) = ""
    6. Next
    7. Clipboard.Clear
    8. Clipboard.SetText Replace(Join(myarr, vbNewLine), vbLf & vbCr, "")
    9. End Sub
    make a project with the above code (no form needed) and compile
    copy from the post
    run program (nothing visible happens)
    paste into whatever code window
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  2. #2
    Junior Member Monkey007's Avatar
    Join Date
    Sep 2007
    Location
    Manchester, UK
    Posts
    17

    Re: copying vbcode from posts

    dam thats a good idea, sick to death of the rsi-deleting needed when using posted code!

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: copying vbcode from posts

    Moved to the CodeBank

    You don't need to do any deleting or formatting.

    If you want a piece of highlighted code, click the quote button. The post you are "quoting" will be displayed in plain text. Just copy the code and then cancel out of the quote.

  4. #4
    Junior Member Monkey007's Avatar
    Join Date
    Sep 2007
    Location
    Manchester, UK
    Posts
    17

    Re: copying vbcode from posts

    true.. but doing it that way you get stuck with place holders you need to remove, westconn1s way has none .. guess it depends on how lazy you are.. and I am lol

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    Re: copying vbcode from posts

    What place holders?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Junior Member Monkey007's Avatar
    Join Date
    Sep 2007
    Location
    Manchester, UK
    Posts
    17

    Re: copying vbcode from posts

    HIGHLIGHT and QUOTE and all the [ and ] bits

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: copying vbcode from posts

    Oh please, you don't copy those, you just copy what is in between them.

  8. #8
    Junior Member Monkey007's Avatar
    Join Date
    Sep 2007
    Location
    Manchester, UK
    Posts
    17

    Re: copying vbcode from posts

    Down to preference then, I prefer the code way, saves me clicking off the post too

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: copying vbcode from posts

    Si_the_geek's VBCode program works even faster. Highlight the code you want to copy and copy it with Alt-C. (I have the program running on startup.)
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  10. #10
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: copying vbcode from posts

    Actually it isn't mine, it's Marty's:
    http://www.vbforums.com/showthread.php?t=458328
    http://www.vbforums.com/showthread.php?t=458438

    (I personally use the Quote & copy method)

  11. #11
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: copying vbcode from posts

    Nice and simple westconn1!
    Just needed to add, dim i as...

  12. #12
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Re: copying vbcode from posts

    Why not just have the forum guys fix the problem. Take those line numbers out. What is the point of them anyway? We used to be able to copy and past code from the forum with no problems.

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: copying vbcode from posts

    It's not as simple as that unfortunately - the current version of the forum software does not support our our old highlighting method, and there aren't options for how the current one works.

    The current method is a decent replacement, even with this relatively minor issue. The development team had various issues to deal with here when we upgraded, and finding/implementing that highlighter was more than they were required to do (they could have just left us with Code tags). As they work on multiple sites (including about 30 forums) which have their own issues, something like this isn't at the top of their list.

    There is work in progress to modify the highlighter to deal with the line numbers (and other minor issues such as colours), but as it not overly simple, and is being done by a moderator (thus voluntarily), it is not something which will happen immediately - but hopefully will be complete in the near future..

  14. #14
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Re: copying vbcode from posts

    I can understand that. This looks like VBulletin forum software. I primarily use PHP forum software which is open source and customizable..but does have draw backs. Perhaps the VBulletin folks can address the issue. It is a big deal in particular for this forum in which programmers indeed like and need to cut and paste code samples quite frequently. That is just my 2 cents. This has always been a great forum...so don't take this as a complaint in a broad regard.

    Thanks!

  15. #15
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: copying vbcode from posts

    It is vBulletin (see the section at the bottom of the page), and it is customisable.. which is why the syntax highlighter (provided by someone else) is available. The issue is with the flexibility of the highlighter, rather than the forums software itself.

    The problem is that while language specific code tags are certainly useful to us, they are not essential (as the standard Code tags could be used - like on many other sites). As such they are not a top priority for the team who keep this site (and several others) operational; we were lucky they did as much as they have done - as they weren't required to do it.

    I understand and agree that the current issues are annoying, but they are not a "must fix", as there are various workarounds like the ones above.

    As I said tho, the implementation is being "corrected" by a volunteer (who has lots of relevant knowledge/experience in this area), and will be hopefully be updated fairly soon.

  16. #16
    PowerPoster Dave Sell's Avatar
    Join Date
    Mar 2004
    Location
    /dev/null
    Posts
    2,961

    Re: copying vbcode from posts

    Pressing [QUOTE] and copy/paste works well, thanks!
    Nobody knows what software they want until after you've delivered what they originally asked for.

    Don't solve problems which don't exist.

    "If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)

    2 idiots don't make a genius.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width