CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2012
    Posts
    4

    Form load event - can't see my labels or my image on my form

    HI,

    I have this code when it runs it opens a blank form (no image or labels) until after my code is done.

    I want the form to show and label to say "Running" then label changes when completed.

    Right now, using the code below - it opens a complety blank form and then adds my labels and image only when it's done.


    Code:
    Private Sub Form_Load()
            
        Form1.Visible = True
        Form1.Image1.Visible = True
        Form1.Label1.Caption = "Starting Import"
        Form1.Command1.Visible = False
            
        
       
       Dim fso As New FileSystemObject
    
        fso.CopyFile "\\WSIPR2\GSAP\TES_REMOTE\ITITES\ITIDATA\Ultidata.mdb", "\\GSDCSHR01\gsap\TES_Remote\ITITES\ITIDATA\Ultidata.mdb"
    	 
      If Dir("\\GSDCSHR01\gsap\TES_Remote\ITITES\ITIDATA\Ultidata2.mdb") <> "" Then Kill _
             "\\GSDCSHR01\gsap\TES_Remote\ITITES\ITIDATA\Ultidata2.mdb"
             DBEngine.CompactDatabase "\\GSDCSHR01\gsap\TES_Remote\ITITES\ITIDATA\Ultidata.mdb", "\\GSDCSHR01\gsap\TES_Remote\ITITES\ITIDATA\Ultidata2.mdb"
    
      Label2.Caption = "Finished Compact and Repair of MDB Files on GSDCSHR01"
      Unload Me
    End Sub

  2. #2
    Join Date
    Oct 2012
    Posts
    4

    Re: Form load event - can't see my labels or my image on my form

    FWIW-

    I'm pretty sure it has to do with FILESYSTEMOBJECT...

    but I'm new to VB.

    If I comment out FSO, then form loads with the image and label.

  3. #3
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Form load event - can't see my labels or my image on my form

    Try using the Paint event instead of Load event
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Form load event - can't see my labels or my image on my form

    The issue is the fact that you are doing it in the load event. Normally the form is not actually displayed until the load event is complete. You can use a refresh, visible or show method in the form load to force it to show before the event is complete.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Form load event - can't see my labels or my image on my form

    if it wasn't so extremely painful creating threads in VB 6, or even worse multi-threading, then I'd have suggested that. Or even the BackgroundWorker .NET component....

  6. #6
    Join Date
    Oct 2012
    Posts
    4

    Re: Form load event - can't see my labels or my image on my form

    Thanks guys...

    I added the code like this and it worked! Thasnk again..

    Code:
    Private Sub Form_Load()
    '
        Form1.Refresh
        Form1.Show
        Form1.AutoRedraw = True
        Form1.Visible = True
        Form1.Image1.Visible = True
        Form1.Label1.Caption = "Starting Copy of open MDB Files"
        Form1.Command1.Visible = False
    
    
        'Label1.Caption = "Starting Copy of MDB Files from WSIPR2"
       
       Dim fso As New FileSystemObject
        Form1.Refresh
        Form1.Show
        Form1.AutoRedraw = True
        Form1.Visible = True
        Form1.Image1.Visible = True
        Form1.Label1.Caption = "Starting Copy of open MDB Files"
        Form1.Command1.Visible = False

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Form load event - can't see my labels or my image on my form

    A bit of overkill there but I suppose it would work. You only need one call to show or visible for your form. Refresh would be used once you updated display objects but you should be able to get it to work with a single me.refresh and a me.show
    Always use [code][/code] tags when posting code.

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Form load event - can't see my labels or my image on my form

    krypto, please mark your thread resolved if you feel the issue has been resolved

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

Featured