chris_rulez001 Posted July 27, 2008 Share Posted July 27, 2008 hey im having trouble with a vb progressbar. code: Public Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = "" Timer1.Enabled = True Timer1.Start() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If ProgressBar1.Value = ProgressBar1.Minimum Then ProgressBar1.Value = 1 ProgressBar1.Value = ProgressBar1.Value + 1 Label1.Text = "Initializing Game Route" End If If ProgressBar1.Value = 45 Then Label1.Text = "Initializing Graphics" End If If ProgressBar1.Value = 60 Then Label1.Text = "Initializing Controls" End If If ProgressBar1.Value = 88 Then Label1.Text = "Initalizing Game" End If If ProgressBar1.Value >= ProgressBar1.Maximum Then Timer1.Stop() Me.Hide() Form1.Show() End If End Sub End Class all its doing is putting progressbar1's value as 2. can someone help please? i am confused ??? Quote Link to comment https://forums.phpfreaks.com/topic/116892-an-annoying-vb-progressbar/ Share on other sites More sharing options...
chris_rulez001 Posted July 28, 2008 Author Share Posted July 28, 2008 ive fixed it now, ive changed my code heres the working code: Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim random As New Random Timer1.Interval = random.Next(100, 1000) If ProgressBar1.Value = ProgressBar1.Maximum Then Timer1.Stop() Me.Hide() Form1.Show() Else ProgressBar1.Value += random.Next(1, 3) If ProgressBar1.Value = 4 Then Label1.Text = "Initializing Game Route" ElseIf ProgressBar1.Value = 45 Then Label1.Text = "Initializing Graphics" ElseIf ProgressBar1.Value = 60 Then Label1.Text = "Initializing Controls" ElseIf ProgressBar1.Value = 88 Then Label1.Text = "Initalizing Game" End If End If End Sub for people using this code, the bits in red can be changed or removed Quote Link to comment https://forums.phpfreaks.com/topic/116892-an-annoying-vb-progressbar/#findComment-602018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.