Jun 13, 2010 09:17 AM
(This post was last modified: Jun 13, 2010 09:18 AM by The-One.)
Hello people!
Today i'm going to teach you beginners in vb.net how to make a progress bar.
Needs:
- Visual basic 2008/2010
- New Project
- 1 Form
What are we going to do?
I'm going to make the progressbar show values and when it reach's a value it pops a message box with the time (in seconds) how long it took to reach the value.
Okey, this is my GUI:
[img]http://i48.[censored].com/126bnd3.png[/img] (ALSO ADD A TIMER! )
Coding:
Double click the button1(Text=Start):
*= Make the progressbar's maximum value 10, if you can't find it, add ProgressBar1.Maximum = 10 to form1.load
Next, Form1.Load:
After that, double click the timer (Timers interval= 500):
And if u did it all right, you got 1 error at the GRN(GenerateRandomNumber)(Add this somewhere in your form class):
Full Source:
Spoiler (Click to View)
Enjoy!
Rate,Comment etc. etc!
Today i'm going to teach you beginners in vb.net how to make a progress bar.
Needs:
- Visual basic 2008/2010
- New Project
- 1 Form
What are we going to do?
I'm going to make the progressbar show values and when it reach's a value it pops a message box with the time (in seconds) how long it took to reach the value.
Okey, this is my GUI:
[img]http://i48.[censored].com/126bnd3.png[/img] (ALSO ADD A TIMER! )
Coding:
Double click the button1(Text=Start):
Code
If Timer1.Enabled = False Then ' If the timer isn't running do:
Timer1.Start() ' Start the timer
Button1.Text = "Stop" ' Change buttons text from start to stop
Else ' If it is running do:
Timer1.Stop() ' Stop the timer
Button1.Text = "Start" ' Change buttons text from stop to start
ProgressBar1.Value = 0 ' Change the progressbar's value to 0*
End IfNext, Form1.Load:
Code
' This is what we are going to use as a count system
Label1.Text = "0"
Label2.Text = "0"After that, double click the timer (Timers interval= 500):
Code
Dim Nmr As Integer = 0 ' Define a integer
ProgressBar1.Value = GRN(1, 11) ' Generate a random value
Label1.Text = Label1.Text + 1 ' Count + 1
If Label1.Text = 2 Then ' If count = 2 (500*2=1000 = 1 SEC)
Label1.Text = 0 ' Count = 0 (restart counting)
Label2.Text = Label2.Text + 1 ' Seconds + 1
End If
If ProgressBar1.Value = 10 Then ' If its 10
Timer1.Stop() ' Stop the timer
MsgBox("Maximum Reached In: " & Label2.Text & " Secconds.") 'Draw a message with the message and the secconds
End IfAnd if u did it all right, you got 1 error at the GRN(GenerateRandomNumber)(Add this somewhere in your form class):
Code
Public Function GRN(ByVal min As String, ByVal max As String)
Dim RD As New Random() ' Define RD as random class
Dim RN As Integer ' Define Rn as a integer
RN = RD.Next(min, max) ' Randomize a number between min & max
Return RN ' Return the randomized number
End FunctionFull Source:
Spoiler (Click to View)
Enjoy!
Rate,Comment etc. etc!
FR1908

