loop help

rangerbud249

Active member
Joined
Aug 18, 2004
Messages
27
Programming Experience
Beginner
I have 52 of these statements. Can someone please help me make them a loop or do until statement?

If weekVar Is W1 Then
W1 = e.Item.Cells(2).Controls(0)
Else
W1 = Nothing
End If
If weekVar Is W2 Then
W2 = e.Item.Cells(2).Controls(0)
Else
W2 = Nothing
End If
If weekVar Is W3 Then
W3 = e.Item.Cells(2).Controls(0)
Else
W3 = Nothing
End If

thanks,

Jose
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
VB.NET:
dim blnExitLoop as boolean = false
 do while blnExitLoop = False
  If weekVar Is W1 Then
  W1 = e.Item.Cells(2).Controls(0)
  Else
  W1 = Nothing
  End If
  If weekVar Is W2 Then
  W2 = e.Item.Cells(2).Controls(0)
  Else
  W2 = Nothing
  End If
  If weekVar Is W3 Then
  W3 = e.Item.Cells(2).Controls(0)
  Else
  W3 = Nothing
  End If
 loop
now all you need to do is somewhere in there have it change the blnExitLoop equal to True otherwise you have a never ending loop which is a bad thing IMO
 
Top Bottom