[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!
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.
Re: [2008] creating a fake progress bar
Quote:
Originally Posted by
user name
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
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?
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
Re: [2008] creating a fake progress bar
Quote:
Originally Posted by
techgnome
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.
Re: [2008] creating a fake progress bar
Quote:
Originally Posted by
user name
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