Results 1 to 4 of 4

Thread: timer and auto loading of form problems...please help...

  1. #1

    Thread Starter
    Registered User
    Join Date
    Nov 2005
    Posts
    206

    Question timer and auto loading of form problems...please help...

    ok, so i have 3 times, to each change the rate that the progressbar progresses...

    and at the end, i want it to click on the form to load the rest of the app...

    and i get an 'object reference not set to an instance of an object'..

    VB Code:
    1. Private Sub frmSplash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         tmrLoadDB.Enabled = True
    3.         lblLoadingDB.BringToFront()
    4.     End Sub
    5.  
    6.     Private Sub tmrLoadDB_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles tmrLoadDB.Elapsed
    7.  
    8.         progBarMain.Value = progBarMain.Value + 1
    9.         If progBarMain.Value >= 45 Then
    10.             tmrLoadDB.Enabled = False
    11.             tmrLoadForms.Enabled = True
    12.         End If
    13.  
    14.     End Sub
    15.  
    16.     Private Sub tmrLoadForms_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles tmrLoadForms.Elapsed
    17.         lblLoadForms.BringToFront()
    18.         progBarMain.Value = progBarMain.Value + 1
    19.         If progBarMain.Value >= 150 Then
    20.             tmrLoadForms.Enabled = False
    21.             tmrSecPol.Enabled = True
    22.         End If
    23.     End Sub
    24.  
    25.     Private Sub tmrSecPol_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles tmrSecPol.Elapsed
    26.         lblLoadSecPol.BringToFront()
    27.         progBarMain.Value = progBarMain.Value + 1
    28.         If progBarMain.Value = 200 Then
    29.             tmrSecPol.Enabled = False
    30.         End If
    31.  
    32.     End Sub
    33.  
    34.     Private Sub frmSplash_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click
    35.         If tmrLoadDB.Enabled = False And tmrLoadForms.Enabled = False And tmrSecPol.Enabled = False Then
    36.             Dim loginForm As Sparticus.frmLogin
    37.             loginForm.Activate()
    38.         End If
    39.     End Sub

    thanks everyone, Justin

  2. #2
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461

    Re: timer and auto loading of form problems...please help...

    I guess you need to insert a NEW.
    From:
    Dim loginForm As Sparticus.frmLogin
    To
    Dim loginForm As New Sparticus.frmLogin
    Live long and prosper (Mr. Spock)

  3. #3

    Thread Starter
    Registered User
    Join Date
    Nov 2005
    Posts
    206

    Re: timer and auto loading of form problems...please help...

    Quote Originally Posted by alextyx
    I guess you need to insert a NEW.
    From:
    Dim loginForm As Sparticus.frmLogin
    To
    Dim loginForm As New Sparticus.frmLogin
    Thanks, ill remember that for next time...

    i just used a sub main() procedure, and an if me.dialogresult = ok statement...

    VB Code:
    1. Public Shared Sub Main()
    2.         Application.EnableVisualStyles()
    3.         Application.DoEvents()
    4.         Dim splash As New frmSplash
    5.  
    6.         If splash.ShowDialog() = Windows.Forms.DialogResult.OK Then
    7.             splash.Dispose()
    8.             Application.Run(New frmLogin)
    9.         Else
    10.             splash.Dispose()
    11.         End If
    12.     End Sub
    13.  
    14.     Private Sub tmrSecPol_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles tmrSecPol.Elapsed
    15.         lblLoadSecPol.BringToFront()
    16.         progBarMain.Value = progBarMain.Value + 1
    17.         If progBarMain.Value = 200 Then
    18.             tmrSecPol.Enabled = False
    19.             Me.DialogResult = Windows.Forms.DialogResult.OK
    20.         End If
    21.  
    22.     End Sub

    that works fine for me...thanks for the reply, Justin

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: timer and auto loading of form problems...please help...

    Argh! I don't like Hungarian notation but I particularly dislike it when it's used in type names. Hungarian notation is for variables, so if you have a form variable it may be appropriate to prefix its name with "frm", but if you derive a class from the Form class it is not appropriate to prefic it with "frm". If were going to use Hungarian notation in that situation then you would use "cls" for Class, but that's just silly. Anyway, enough ranting. Activate is like Focus. You can't focus something that isn't visible. You need to Show the form first. You also need to create it, so do follow alextyx's advice too.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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