Results 1 to 6 of 6

Thread: quick qustion.. form finished loading event

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2001
    Posts
    283

    quick qustion.. form finished loading event

    what handle do i put on a sub so that it gets called when a form is completely finished loading and all its components are initialized?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You can use the Activate(d) event but it will fire also if the form comes back into focus from another app or form. To make it only fire once wrap a flag check around it:
    VB Code:
    1. Static HasRan As Boolean=False
    2. If Not HasRan Then
    3.    'put code here
    4.    HasRan=True
    5. End If

  3. #3

    Thread Starter
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    can you have a sub that executes every time the form loads, without being called by an event, as if it were a console application, for example?

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The only thing outside of an event would be the constructor. Why?

  5. #5

    Thread Starter
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    what if, for example you have a textbox that you want to display the time the application started.
    where would you set textbox.text = Now().tostring() ???
    if you do it in the form designer generated constructor of the textbox, then you can't use the design mode of the form anymore, because vb can't interpret the expression now() at design time and you get an error.

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You could use the Load event for that. You could also put it in the constructor after the line that reads: 'Add any initialization after the InitializeComponent() call
    ALso if there are any parameters that you want to pass in then you would Overload the constructor to keep the designer working:

    Public Sub New(something As String)
    Me.New()

    'do something with something here
    End Sub

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