Does anyone know visual basic?

Started by mrapoc, Nov 03, 2007, 11:30:29

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

mrapoc

Its a bit complex for me:

Basically I want to add a time-based progress bar purely for appearance.

I know i need to either make a loop or, use a time based command. My lecturer didnt want to go that far but hes pleased im experimenting and wants me to have a go at home/do some research.

Im basically just trying to see how many simple yet cool things i can implement.

Heres is my code, you can probably guess what it does if you know how to add this damn progress bar!

I then want to make a picture/event happen after progress bar fills -but i think i can manage that

Quote

Public Class Form1

Private Sub ButtonPress_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPress.Click
'gives a message related to user's name and shows time
LblOutput.Text = "Hello, " & TBInsertText.Text & ", Would you like to see a cool picture?"
LblOutput.Visible = True

TheTime.Text = "The time is: " & TimeOfDay
TheTime.Visible = True




End Sub


Private Sub TBInsertText_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TBInsertText.Click
'blanks text from box when clicked for user input
TBInsertText.Text = ""




End Sub

Private Sub ButtonPress_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ButtonPress.MouseClick
'makes button visible after pressing "press me"
PictureButton.Visible = True

End Sub


Private Sub PictureButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureButton.Click
'Makes picture button blue when pressed and makes progress bar visible
PictureButton.BackColor = Color.Blue
ProgressBar1.Visible = True


End Sub
End Class 

Cheers

mogden

Something like this should do the trick:

You'll need a couple of declarations at the class level:

    Private Shared mytimer As New System.Windows.Forms.Timer() 'timer
    Private Shared exitFlag As Boolean = False 'exit flag

Then Two subs:

Private Sub PictureButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureButton.Click

'Makes picture button blue when pressed and makes progress bar visible

PictureButton.BackColor = Color.Blue

        With ProgressBar1 ' set up minimum and maximum values
            .Minimum = 0
            .Maximum = 100
            .Value = 0
            .Visible = True
        End With

        AddHandler mytimer.Tick, AddressOf timereventprocessor ' timer one second interval
        mytimer.Interval = 1000
        mytimer.Start()

        While exitFlag = False ' keep going until exitflag is true
            Application.DoEvents()
        End While

End Sub

    Private Sub timereventprocessor(ByVal myobject As Object, ByVal myeventargs As EventArgs)

        mytimer.Stop()

        Me.ProgressBar1.Value = Me.ProgressBar1.Value + 10 ' add 10 to progressbar value
        If Me.ProgressBar1.Value < 100 Then
            mytimer.Enabled = True
        Else
            exitFlag = True
        End If

    End Sub
Matt

ceci n'est pas un .sig

mrapoc

Cheers mate I sorted it

Added a timer
Made a relation between timer interval and progress bar value and it works now  :laugh:

Karma for your effort  ;)