Results 1 to 19 of 19

Thread: [RESOLVED] Splash Screen

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] Splash Screen

    I have created a splash screen for my app, added a progress bar on the bottom and a timer.

    Added the following code (complete) and get the following error message:
    Run-time error ' 380':
    Invalid property value

    highlighted:
    VB Code:
    1. ProgressBar1.Value = ProgressBar1.Value + 1

    complete code:
    VB Code:
    1. Private Sub Form_Load()
    2.     Timer1.Interval = 1000
    3.    
    4.     With ProgressBar1
    5.         .Max = 10
    6.         .Value = 0
    7.     End With
    8. End Sub
    9.  
    10. Private Sub Timer1_Timer()
    11.     ProgressBar1.Value = ProgressBar1.Value + 1
    12.    
    13.     If ProgressBar1.Value = ProgressBar1.Max Then
    14.     frmTranslator.Show
    15.     frmSplash.Hide
    16.     End If
    17. End Sub
    18.  
    19. Private Sub Form_Click()
    20.     Unload Me
    21.     frmTranslator.Show
    22. End Sub
    23.  
    24. Private Sub Form_KeyPress(KeyAscii As Integer)
    25.     Unload Me
    26.     frmTranslator.Show
    27. End Sub

    Please advise.
    Last edited by BrailleSchool; May 7th, 2005 at 01:46 AM.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Splash Screen

    VB Code:
    1. If ProgressBar1.Value = ProgressBar1.Max Then
    2.     [hl]Timer1.Enabled = False[/hl]
    3.     frmTranslator.Show
    4.     frmSplash.Hide
    5. End If

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Splash Screen

    Quote Originally Posted by penagate
    VB Code:
    1. If ProgressBar1.Value = ProgressBar1.Max Then
    2.     [hl]Timer1.Enabled = False[/hl]
    3.     frmTranslator.Show
    4.     frmSplash.Hide
    5. End If
    That worked, thanks. Now to find out on the forum if adding text to the progress bar is easy to do.... for example: 0% to 100%

    Found exactly what I was looking for here:
    http://www.vbforums.com/showthread.p...gress+bar+text
    Last edited by BrailleSchool; May 4th, 2005 at 12:24 AM.

  4. #4
    Lively Member
    Join Date
    Apr 2005
    Posts
    68

    Re: [RESOLVED] Splash Screen

    How about make a textbox and add the following code to your Timer Event
    VB Code:
    1. lblPercent.caption = int(ProgressBar1.Max / ProgressBar1.Value) & "%"

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: [RESOLVED] Splash Screen

    Backwards, though;

    VB Code:
    1. lblPercent.caption = int( ProgressBar1.Value / ProgressBar1.Max  ) & "%"

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: [RESOLVED] Splash Screen

    Quote Originally Posted by dglienna
    Backwards, though;

    VB Code:
    1. lblPercent.caption = int( ProgressBar1.Value / ProgressBar1.Max  ) & "%"
    Its not quite working the way it is supposed to. This is what I have so far. When the progress bar reaches 100% then the splash screen hides and the other form shows

    VB Code:
    1. Private Sub DrawProgress(ByVal Value As Long, ByVal Max As Long)
    2. Dim strPercent As String
    3. Dim intPercent As Integer
    4. Dim intWidth As Integer
    5. Dim intHeight As Integer
    6.  
    7.     intPercent = (Value / Max) * 100
    8.     strPercent = intPercent & "% Complete"
    9.     intWidth = Picture1.TextWidth(strPercent)
    10.     intHeight = Picture1.TextHeight(strPercent)
    11.  
    12.     With Picture1
    13.         .FillStyle = vbFSSolid
    14.         .BackColor = vbWhite
    15.         .ForeColor = vbBlue
    16.         .DrawMode = vbCopyPen
    17.         .CurrentX = (Picture1.ScaleWidth - intWidth) / 2
    18.         .CurrentY = (Picture1.ScaleHeight - intHeight) / 2
    19.         Picture1.Print strPercent
    20.         .DrawMode = vbNotXorPen
    21.     End With
    22.  
    23.     If intPercent > 0 Then
    24.         Picture1.Line (-50, -50)-(Picture1.Width * intPercent / 100, Picture1.Height), vbBlue, BF
    25.     Else
    26.         Picture1.Line (-50, -50)-(Picture1.Width, Picture1.Height), vbWhite, BF
    27.     End If
    28.         Picture1.Refresh
    29.         If intPercent = 100 Then
    30.         'hide the splash screen
    31.         frmSplash.Hide
    32.         'show my form
    33.         frmTranslator.Show
    34.         End If
    35. End Sub
    Last edited by BrailleSchool; May 4th, 2005 at 01:00 AM.

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: [ALMOST-RESOLVED] Splash Screen

    Its not quite working the way it is supposed to. This is what I have so far. When the progress bar reaches 100% then the splash screen hides and the other form shows

    1) What is the problem? Isn't that the way it's supposed to work? When the pb gets to 100% it closes and the form opens?

    2) You aren't using a Progress Bar? Look at this example to see what I mean.
    It's simple, and uses a loop for movement, but it uses the progress bar control.
    Attached Files Attached Files

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: [ALMOST-RESOLVED] Splash Screen

    Quote Originally Posted by dglienna
    1) What is the problem? Isn't that the way it's supposed to work? When the pb gets to 100% it closes and the form opens?

    2) You aren't using a Progress Bar? Look at this example to see what I mean.
    It's simple, and uses a loop for movement, but it uses the progress bar control.
    The progress bar is a picture box to look like a progress bar that has 0% to 100% as the progress bar increases.

    When the bar gets to 100%, the splash hides and the main form shows, but when you click off the main form, a few seconds later, the main form comes back and then a domino effect. The only way to completely close down the app is to do alt+ctrl+del

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: [ALMOST-RESOLVED] Splash Screen

    In the lost focus event, put a timer.enabled = false, and a unload form.

  10. #10
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: [ALMOST-RESOLVED] Splash Screen

    In that case, use
    VB Code:
    1. Unload frmSplash
    2. 'instead of
    3. 'frmSplash.Hide
    Also, if you are using a picturebox as a progressbar, use something like:
    VB Code:
    1. picProgress.CurrentX = (picProgress.ScaleWidth / 2) - (picProgress.TextWidth("X") / 2)
    2. picProgress.CurrentY = (picProgress.ScaleHeight / 2) - (picProgress.TextHeight("X") / 2)
    3. picProgress.Print "x%"
    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: [ALMOST-RESOLVED] Splash Screen

    Quote Originally Posted by dglienna
    In the lost focus event, put a timer.enabled = false, and a unload form.
    any lostfocus even just allows the progress bar to refresh and the splash screen stays on screen.

  12. #12
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: [ALMOST-RESOLVED] Splash Screen

    This'll do it:
    VB Code:
    1. If ProgressBar1.Value = ProgressBar1.Max Then
    2.     Timer1.Enabled = False
    3.     frmTranslator.Show
    4.     Unload frmSplash
    5.     'frmSplash.Hide
    6. End If
    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: [ALMOST-RESOLVED] Splash Screen

    Yes. If you hide the form, it will come back with the MAX reached with the bar, and get stuck. You need to unload the form.

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: [ALMOST-RESOLVED] Splash Screen

    Quote Originally Posted by «°°phReAk°°»
    This'll do it:
    VB Code:
    1. If ProgressBar1.Value = ProgressBar1.Max Then
    2.     Timer1.Enabled = False
    3.     frmTranslator.Show
    4.     Unload frmSplash
    5.     'frmSplash.Hide
    6. End If
    Phreak
    I was thinking about that before I came back and I did something similar which also worked. Nothing has come back on screen after clicking off the main form.

    I did:

    VB Code:
    1. If intPercent > 0 Then
    2.         Picture1.Line (-50, -50)-(Picture1.Width * intPercent / 100, Picture1.Height), &H4000&, BF
    3.     Else
    4.         Picture1.Line (-50, -50)-(Picture1.Width, Picture1.Height), vbWhite, BF
    5.     End If
    6.         Picture1.Refresh
    7. 'if the progress bar reaches 100% then
    8.         If intPercent = 100 Then
    9. 'disable the timer
    10.         Timer1.Enabled = False
    11. 'hide the splash screen
    12.         frmSplash.Hide
    13. 'show the main screen
    14.         frmTranslator.Show
    15.         End If
    16. End Sub

  15. #15
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: [ALMOST-RESOLVED] Splash Screen

    Quote Originally Posted by «°°phReAk°°»
    This'll do it:
    VB Code:
    1. If ProgressBar1.Value = ProgressBar1.Max Then
    2.     Timer1.Enabled = False
    3.     frmTranslator.Show
    4.     Unload frmSplash
    5.     'frmSplash.Hide
    6. End If
    Phreak
    No progress bar, though...

    VB Code:
    1. If Value = Max Then
    2.     Timer1.Enabled = False
    3.     frmTranslator.Show
    4.     Unload frmSplash
    5.     'frmSplash.Hide
    6. End If

  16. #16
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: [ALMOST-RESOLVED] Splash Screen

    Although, instead of using frmSplash.Hide, you should still unload it, as it will cause errors later if you aren't using it again. Or, if you don't want to do that, use something like this in the "Exit" part of your code:
    VB Code:
    1. Dim j As Form
    2. For Each j In Forms
    3. Unload j
    4. Next
    ..to unload all the forms.

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: [ALMOST-RESOLVED] Splash Screen

    Quote Originally Posted by «°°phReAk°°»
    Although, instead of using frmSplash.Hide, you should still unload it, as it will cause errors later if you aren't using it again. Or, if you don't want to do that, use something like this in the "Exit" part of your code:
    VB Code:
    1. Dim j As Form
    2. For Each j In Forms
    3. Unload j
    4. Next
    ..to unload all the forms.

    Phreak
    definately a valid point you have there. i didnt think about that. must be the newb coming out in me.

    i am going to have to research how to unload the form because i only know how to do it when you click on something.... time to search the braille book on this one haha

    found it
    VB Code:
    1. unload frmSplash
    Last edited by BrailleSchool; May 4th, 2005 at 01:51 AM.

  18. #18
    Addicted Member spyk3's Avatar
    Join Date
    Apr 2009
    Location
    Dothan, AL
    Posts
    218

    Re: [RESOLVED] Splash Screen

    I havn't read all the post and this might have been stated, but you could just as easily just add a loading command (step subroutine) for whatever it is that takes ur form so long to load
    For instance, I have variety of apps that build database (or retrieve info rather) upon load so that user interaction during prog is not slowed by streaming feeds, I simply load in at start and load out at close (datagrids filled and things) anyway, point is, i add a "splashscreen" which generally just has a progress bar and the word loading or somthing to that effect.
    Then on my main form, whever ever the largest chunck of work is being done on load (ie the For Each in database statements), I add one simple line just before "Next" - stepProBar()

    the code for it is simple tho you'll need to delagate it on splash form since it's on seperate thread.

    To make this easier, add ur splash screen, add a probar to the splash screen
    in splash screen code put :
    proBar Code:
    1. Delegate Sub stepBarI(ByVal i As Integer)
    2.     Public Sub stepI(ByVal i As Integer)
    3.         If Me.ProgressBar1.InvokeRequired = True Then
    4.             Dim d As New stepBarI(AddressOf stepI)
    5.             Invoke(d, New Object() {i})
    6.         Else
    7.             Me.ProgressBar1.Value += i
    8.         End If
    9.     End Sub
    10.  
    11.     Public Sub stepBar()
    12.         If Me.Visible = True Then
    13.             If Me.ProgressBar1.Value < Me.ProgressBar1.Maximum Then
    14.                 stepI(1)
    15.             Else
    16.                 stepI(0)
    17.             End If
    18.         End If
    19.     End Sub

    then ofcourse on your main form, wherever the main work is going on put "stepBar" for each loading command, example:

    mainForm Code:
    1. Public Sub prepDatabase()
    2.         For Each item In yourDatabase
    3.             ArrayList.Add(item)
    4.             stepbar() <---Here it will step 1 interval after every added item
    5.         Next
    6.     End Sub 'this is a really bad example but u should get the idea

    this is not likly the best way, but it's what has worked great for me so far, so i figured i'd add, timers can be messy and seem to cause more overhead, this method is very light on my cpu
    enjoy
    Last edited by spyk3; Feb 15th, 2010 at 05:51 PM. Reason: really bad last example! :-P

  19. #19
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] Splash Screen

    This thread is ancient history.

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