Running text in the buttons

  • Thread starter Thread starter tony wong
  • Start date Start date
T

tony wong

i have 2 questions

1. click button1, button1.text run. click button2, button2.text run.

2. multithreading - 2 buttons run at the same time.


Thanks a lot.

*******************************
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click, Button2.Click

Dim a As Integer
For a = 1 To 500
Button1.Text = a
Application.DoEvents()
Next

End Sub
 
tony wong said:
i have 2 questions

1. click button1, button1.text run. click button2, button2.text
run.

2. multithreading - 2 buttons run at the same time.


Thanks a lot.

*******************************
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click, Button2.Click

Dim a As Integer
For a = 1 To 500
Button1.Text = a
Application.DoEvents()
Next

End Sub

Usually don't use DoEvents. Multithreading is IMO not a good solution in
this case, too.

I'd use a Timer (System.Windows.Forms.Timer) for this purpose. In the
Timer's Tick event, update the Button text.


Armin
 
Back
Top