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:

malitice

Active member
Joined
Feb 20, 2005
Messages
41
Programming Experience
1-3
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.
 

sonotarv

New member
Joined
Feb 24, 2005
Messages
4
Programming Experience
Beginner
If i use the new code..only the backcolor of label1 change.

nothing happens with the other labels.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-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
 
Top Bottom