It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

For Loop

Moderator: dafunkymunky

For Loop

Postby kamran619 on Wed Oct 08, 2008 1:36 am

Hey everyone, I am new to this forum and needed help with a loop

It will compare the array of football teams to txtpicks.text using thee delimiter ","

They will both be split into arrays and if each andevery pick do not equal the right team then msgbox and error and exit sub and not send the picks to the server...any team just needs to make them be sent to the server exactly as shown...

Every time i run this I get a next without For error on the lne that says
'Next Y'


Can someone pleasse help?
Code: Select all
Dim Orig As String
Dim Chosen() As String
Dim Y As Integer
Dim X As Integer

Dim Teams(33) As String
Teams(0) = "NFL"
Teams(1) = "ARI"
Teams(2) = "ATL"
Teams(3) = "BAL"
Teams(4) = "BUF"
Teams(5) = "CAR"
Teams(6) = "CHI"
Teams(7) = "CIN"
Teams(8) = "CLE"
Teams(9) = "DAL"
Teams(10) = "DEN"
Teams(11) = "DET"
Teams(12) = "GB"
Teams(13) = "HOU"
Teams(14) = "IND"
Teams(15) = "JAX"
Teams(16) = "KC"
Teams(17) = "MIA"
Teams(18) = "MIN"
Teams(19) = "NE"
Teams(20) = "NO"
Teams(21) = "NYG"
Teams(22) = "NYJ"
Teams(23) = "OAK"
Teams(24) = "PHI"
Teams(25) = "PIT"
Teams(26) = "SD"
Teams(27) = "SEA"
Teams(28) = "SF"
Teams(29) = "STL"
Teams(30) = "TB"
Teams(31) = "TEN"
Teams(32) = "WAS"

Orig = txtPicks.Text
Chosen() = Split(Orig, ",")
Dim Match As Boolean
For Y = LBound(Chosen) To UBound(Chosen)
    For X = 1 To 32 'LBound(Teams) To UBound(Teams)


If Teams(X) = Chosen(Y) Then
X = 0
Next Y
Else
Match = False
Next X
If Match = False Then
MsgBox "NotGood"
'exit the sub and not send data to server
elseif match=true then
'senddata
End If
End If
kamran619
 
Posts: 3
Joined: Wed Oct 08, 2008 1:28 am

Postby mbshinde78 on Wed Oct 08, 2008 12:35 pm

Hey,

You cannot write Next inside IF condition. It is wrong. Use different logic.
mbshinde78
 
Posts: 16
Joined: Tue Sep 09, 2008 1:07 pm


Who is online

Users browsing this forum: No registered users and 6 guests