Jump to content

Recommended Posts

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 ???

Link to comment
https://forums.phpfreaks.com/topic/116892-an-annoying-vb-progressbar/
Share on other sites

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.