Results 1 to 17 of 17

Thread: VB6 clears the clipboard when starting..

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    VB6 clears the clipboard when starting..

    Hello,

    Is there a fix or patch of some sort that will STOP VB6 from clearing the clipboard when it starts?

    Thanks!

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Re: VB6 clears the clipboard when starting..

    Found this in a Google group. I guess there is always a way...but still open to suggestions...



    On Mon, 21 Oct 2002 14:02:15 -0500, "Norm Cook"


    <normc...@cableone.net> wrote:
    >Sigh, just something we have to live with. It's burned me so many times
    >that I've learned to start VB before doing any copying.


    Well, maybe not. If this thing works for you guys too then i guess a
    couple of problems are solved. It's a quick and dirty hack, i'm sure
    there are some more elegant ways, but i coldn't be arsed.
    So it may need some tender loving play with extending or reducing the
    timeout in the for next loop but you guys are programmers right ? :-)

    All in a standard module, formless code.
    I called this vb66.exe and changed the path in the file associations
    "open" to point at this exe instead.
    So far so good, it keeps my clipboard intact and i'm starting up in my
    project directory too. Double whammy and so far so good. :-)


    Nb: Not tested on NT/2k/XP let me know how you went.


    Option Explicit


    'CHANGE THIS TO YOUR VB EXE's PATH
    Code:
    Private Const VBPath = "c:\mvs\vb98\vb6.exe" 
    
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias _ 
    "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As _ 
    String, ByVal lpFile As String, ByVal lpParameters As String,  _ 
    ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long 
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds _ 
    As Long) 
    
    
    Sub Main() 
        Dim saveBuffer As String 
        Dim startPath As String 
        Dim i As Long, ct As Long, ret As Long 
    
    
        'check for and grab any text 
        If Clipboard.GetFormat(vbCFText) = True Then 
            saveBuffer = Clipboard.GetText 
        End If 
        'eval the commandline and grab the project path. 
        If Command$ <> "" Then 
            i = InStrRev(Command$, "\") 
            If i Then 
                startPath = Left$(Command$, i) 
                Else 
                    startPath = "" 
            End If 
        End If 
    
    
        'ask the user to use project path or not. 
        ' if it bugs you get rid of this.   
        Select Case MsgBox("Set path to : " & vbCrLf & _ 
                startPath, vbYesNoCancel Or vbDefaultButton1, _ 
                "About to launch VB") 
            Case vbYes: ' just break 
            Case vbNo: startPath = "" 'don't care 
            Case vbCancel: End ' I'm already denying this. 
        End Select 
    
    
        'launch VB 
        ret = ShellExecute(0, "open", VBPath, Command$, startPath, 1) 
        If ret <= 32 Then 
            MsgBox ("Failed to launch VB") 
            saveBuffer = "" 'force a drop through below 
        End If 
    
    
        ct = 0 
    DONE: 
        If saveBuffer <> "" Then 
            Do While Clipboard.GetFormat(vbCFText) = True 'catch the 
    clearing 
                Call Sleep(300) 'hang about until the cb is cleared by VB. 
                DoEvents 
                ct = ct + 1 
                If ct > 100 Then Exit Do ' but have to give up at some 
    time. 
            Loop 
    
    
            On Error Resume Next 
            Clipboard.SetText saveBuffer, vbCFText 
            ' make sure it stuck and VB doesn't clear it again..which it 
            ' does at times :-/ 
            For ct = 1 To 5 
                Call Sleep(300) 
                If (Clipboard.GetFormat(vbCFText) <> True) Then 
                    Clipboard.SetText saveBuffer, vbCFText 
                End If 
            Next 
        End If 
        ' if we're lucky we should still have a clipboard full of goodies 
    End Sub
    --
    Regards, Frank
    Last edited by birthjay; Aug 29th, 2007 at 03:16 PM. Reason: Can't ever copy code with this dumb thing.

  3. #3
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: VB6 clears the clipboard when starting..

    Are you using SP6?

    I had the same problem a while ago, but after installing SP6 everything remained in the clipboard when starting VB6.

    http://www.microsoft.com/downloads/d...displaylang=en

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Re: VB6 clears the clipboard when starting..

    Thanks...but I can't install it because we develop with SP5. Good to know they must have fixed it though.

  5. #5

  6. #6
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: VB6 clears the clipboard when starting..

    I am running VB6 SP6 and I have not had any problems - until recently when I installed the VBCodeHelper addin. Now when ever I start VB the clipboard is erased. Disabling VBCodeHelper instantly restores normal behaviour.

    Hope this helps.

  7. #7

  8. #8
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: VB6 clears the clipboard when starting..

    Nope! and I just tried it again to prove the point. I copied all of the code in post #2 and then started VB. Tried to paste into the form - nothing!

    Same as above but I disabled VBCodeHelper before quitting the programme, copied the code, started VB and viola!! Are you certaikn that the normal behaviour of VB is to clear the clipboard?

    I have come up from VB3 - VB5 - VB6 and cannot recall this ever happening before, until last week when I installed VBCodeHelper (great addin though).

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: VB6 clears the clipboard when starting..

    I don't buy it - the entire VB community in the world is suffering since VB5 and you are not?
    You must have something else installed (or missing) that directly affects (in a good way) behaviour.

    btw, what version of VB6 do you have? I've never used anything but Enterprise.

  10. #10
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: VB6 clears the clipboard when starting..

    Well you've actually made me doubt myself, so I've just tried the same things as in my last post. No VBCodeHelper and I can copy your post, start VB and paste it into a form. With VBCodeHelper - nothing.

    VB6 Professional with SP6 and the MS updates to overcome the SP6 bugs.

    I think I've attached an image of my addin manager.

  11. #11
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: VB6 clears the clipboard when starting..

    OK - Here's an update for you. At the weekend I reloaded XP SP2 onto my notebook and, although I had installed VB, I hadn't used it.

    Just tried it out on there and it does exactly what everyone else in the world is getting - Spooky.

    Notebook = HP AMD 2400XP+ - 512MB - XP/SP2
    Main Machine HP AMD X2 3800+ 64bit - 1GB - 32bit XP/SP2

    Wow, look at the time and I have to up at 5.

  12. #12

  13. #13
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: VB6 clears the clipboard when starting..

    Hmmm, interesting observation btw.
    I tried it and if you unload ALL add-ins and also make sure NONE is selected to be loaded at startup then "problem" goes away.

    But that beats the purpose of using add-ins !!!
    And since some of them are loaded by default and ARE quite useful practically nobody bothers to unload them.

    That explains. Thanks Marty for pointing out to that thread.

    ps, after all I'd rather have say Component Services loaded and have VB to clear clipboard then visa versa...

  14. #14
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: VB6 clears the clipboard when starting..

    It's become pretty much a habit for me to highlight the code, open VB, go back to the window, copy, back to VB, and paste. Kind of a pain...but come on...it takes only a few extra seconds. Surely if you're a programmer that can't be too bad...

    I think it would take more time for me to try and break that habit and get used to it not clearing the clipboard at this point.

  15. #15
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: VB6 clears the clipboard when starting..

    I know this is an old thread, but an easy solution is a 3rd party clipboard tool.
    I use Yanky Clipper, it's free and good!
    http://www.intelexual.com/products/YC3/

  16. #16
    Member Undocked Windy's Avatar
    Join Date
    Mar 2009
    Location
    California
    Posts
    38

    Re: VB6 clears the clipboard when starting..

    Hmm, why not use the savesetting/getsettings?

    When form loads, savesetting clipboard data, then getsettings clipboard data?

    Home of Nuova Cartella (Mass Folder Creator)

  17. #17

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