Results 1 to 7 of 7

Thread: [2008] creating a fake progress bar

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Posts
    258

    [2008] creating a fake progress bar

    Alright, I don't know if the Title of the thread is the proper term, but what I'm doing is making a RTS Game in VB.NET, all I want to do is have a Progress Bar go for lets say 30seconds, and then have the Image Appear, but I can't how to make the progress bar go for 30seconds and at the end make it each 100%.


    Thanks!

  2. #2
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    499

    Re: [2008] creating a fake progress bar

    Use a timer, set the maximum value of the progressbar to 30, set the interval of the timer to 1000 and set the enabled to true then in the tick event.
    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            ProgressBar1.Value += 1
            If ProgressBar1.Value = 30 Then
                Timer1.Enabled = False
            End If
    
        End Sub
    You can play with that, make it look faster by changing the interval and maximum values.

  3. #3
    New Member
    Join Date
    Apr 2017
    Posts
    1

    Re: [2008] creating a fake progress bar

    Quote Originally Posted by user name View Post
    Use a timer, set the maximum value of the progressbar to 30, set the interval of the timer to 1000 and set the enabled to true then in the tick event.
    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            ProgressBar1.Value += 1
            If ProgressBar1.Value = 30 Then
                Timer1.Enabled = False
            End If
    
        End Sub
    You can play with that, make it look faster by changing the interval and maximum values.
    I got an error while running my script:

    Line: 5
    Char: 38
    Error: expected ')'
    Code: 800A03EE

    here is my script:
    https://pastebin.com/yJQMgUXs

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    Re: [2008] creating a fake progress bar

    You should have just posted your code between [code] tags in your post. I'm not allowed to visit pastebin.com so posting a link to that site is doing me no good.

    You can have this forum's editor place the code tags in the post for you by pressing the button above the Reply window that is showing the "#" symbol.

    You probably should have started a new thread (since this thread is 10 years old) and referenced this thread in your thread if your code is based on it.

    Of course, without seeing the code, the error says it expects a ")" at character 38 of Line 5.
    Did you try adding a ")" at that point in your code to see if the error goes away or changes?

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [2008] creating a fake progress bar

    I took a look at the pastebin code... he litteraly pasted teh entire sub right into the middle of an else statement....
    Which will just not work.

    Code:
    X=MsgBox("Do you agree to free cake?",4+32+4096,"Cake")
    if X="6" then
    Y=MsgBox("There has been an error in baking your free cake. Try again tomorrow.",16+4096,"Windows Bakery")
    else
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
     
            ProgressBar1.Value += 1
            If ProgressBar1.Value = 30 Then
                Timer1.Enabled = False
            End If
     
        End Sub
    I'm not sure where to being.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: [2008] creating a fake progress bar

    Quote Originally Posted by techgnome View Post
    I took a look at the pastebin code... he litteraly pasted teh entire sub right into the middle of an else statement....
    Which will just not work.

    Code:
    X=MsgBox("Do you agree to free cake?",4+32+4096,"Cake")
    if X="6" then
    Y=MsgBox("There has been an error in baking your free cake. Try again tomorrow.",16+4096,"Windows Bakery")
    else
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
     
            ProgressBar1.Value += 1
            If ProgressBar1.Value = 30 Then
                Timer1.Enabled = False
            End If
     
        End Sub
    I'm not sure where to being.

    -tg
    I saw his code from the pastebin, there's sooo much wrong with his code, those MsgBox calls he has especially reminds me of my past vb6 W-T-F programming days.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  7. #7
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,398

    Re: [2008] creating a fake progress bar

    Quote Originally Posted by user name View Post
    Use a timer, set the maximum value of the progressbar to 30, set the interval of the timer to 1000 and set the enabled to true then in the tick event.
    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            ProgressBar1.Value += 1
            If ProgressBar1.Value = 30 Then
                Timer1.Enabled = False
            End If
    
        End Sub
    You can play with that, make it look faster by changing the interval and maximum values.
    If you're going to check if the Value of the property is the most that it can be, then you should be checking if the Value equals the Maximum property. Take a look at this improvement on what you initially suggested:
    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        With ProgressBar1
            .Value += 1
            If .Value = .Maximum Then
                .Enabled = False 'Or .Stop()
            End If
        End With
    End Sub
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

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