Please help! simple problem

FriendlyPhill
09-06-2003, 03:52 PM
I am really new to visual basic and from what i have seen on here it can get pretty technical!

Heres my problem (hope you can help!)

I have a textbox and button i want the textbox to display a pre-defined word when the button is clicked, when the button is clicked a second time another pre-defined word will appear and so on. I also need this to loop so that when the button has been clicked say 5 times and the fifth word is shown it will display the first word again.

I hope that makes sense, thanks all its really appreciated.

BKSwindell
09-06-2003, 04:09 PM
Here, Hope this helps.

'Assumes that Command1 and Label1 are on the form
Dim Word(4) As String 'This declares a string array or a varible that 5 items
Dim I As Integer 'declares a number varable

Private Sub Command1_Click()
If I = 5 Then
I = 0
End If
Label1.Caption = Word(I)
I = I + 1
End Sub

Private Sub Form_Load() 'set the values of the varibles
Word(0) = "One"
Word(1) = "Two"
Word(2) = "Three"
Word(3) = "Four"
Word(4) = "Five"
I = 0
End Sub

FriendlyPhill
09-06-2003, 04:11 PM
Truly thank-you so much! It seems simple to most but this is going to help me a great deal!

Thanks my friend. http://www.visualbasicforum.com/images/icons/icon12.gif

BKSwindell
09-06-2003, 04:12 PM
Truly thank-you so much! It seems simple to most but this is going to help me a great deal!

Thanks my friend. http://www.visualbasicforum.com/images/icons/icon12.gif


No problem, anytime.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum