loop problem

sonotarv

New member
Joined
Feb 24, 2005
Messages
4
Programming Experience
Beginner
code problem

I'm just a beginner and i want to write the code for the next program :
I've 4 labels and 2 buttons on a form

first click : backcolor lbl1 change and with lbl2-lbl3-lbl4 nothing happens
second click : backcolor lbl1 and lbl2 change . with lbl3 and 4 nothing happens
third click :backcolor lbl1 and lbl2 and lbl3 change . lbl4 doesn't change
fourth click : backcolor lbl1 and lbl2 and lbl3 and lbl4 change.
fifth click : the proces start again and the value in lbl2 will increase with one.

ps : everytime the proces start again the value in lbl2 will increase with one.

this proces wil go one till the value in lbl2 is 3. i=i+1
Can somebody tell how the code will look like?.

ps: i've change the tekst to make things more clear i think.
 
Last edited:
Every time you ran the code you reset the value of I

VB.NET:
 Dim i As Integer

and then seperatly:
VB.NET:
 		i = i + 1
 		Select Case i
 
 			Case 1
 
				Label1.BackColor = BackColor.Yellow()
 
 				Label2.BackColor = BackColor()
 				Label3.BackColor = BackColor()
 				Label4.BackColor = BackColor()
 			Case 2
 
 				Label1.BackColor = BackColor()
 
				Label2.BackColor = BackColor.Yellow()
 
 				Label3.BackColor = BackColor()
 				Label4.BackColor = BackColor()
 			Case 3
 				Label1.BackColor = BackColor()
 				Label2.BackColor = BackColor()
				Label3.BackColor = BackColor.Yellow()
 
 				Label4.BackColor = BackColor()
 			Case 4
 				Label1.BackColor = BackColor()
 				Label2.BackColor = BackColor()
 				Label3.BackColor = BackColor()
 
				Label4.BackColor = BackColor.Yellow()
 
 				i = 0
 		End Select

This way it goes no yellow, 1 is yellow ,2 is yellow,3 is yellow,4 is yellow,1 is yellow. To make it go back to none is yellow but i=0 in a case 5.
 
You want to use a loop as you mentioned in your first post. To loop you want to use :
while i < 5

end while

TPM
 

Latest posts

Back
Top