Resolved Array problem

Kasteel7

Member
Joined
Jun 7, 2009
Messages
12
Programming Experience
Beginner
Hi

I have a button that changes the label.text on a form each time the button is pressed. (Different text each time) The button will be presses 20 times.

How can I capture the label.text into an array each time the button is pressed?

Your help would be appreciated.

Thanks :)
 
Last edited:
If you're going to press a button 20 times and expect it to save values to an array with each press, then you need a way to increment the index of the array each time. The best way to do this is by using either a Static variable as a counter, and resetting it to 0 after the 20th time, or using a form-level counter along with a form-level array.

For example, declare form-level:

Private counter As Integer
Private myarray(20) As String

And in the button event:

myarray(counter) = lblLabel.Text
counter += 1
If counter = 20 Then counter = 0
 
Back
Top