tanya tanya - 1 year ago 48
Vb.net Question

VB simple script error compiling loop

I have a VERY simple script yet it is giving me an error while compiling it:

Sub Unit_Status()

Dim temp, w, j
On Error Resume Next

For j=0 To 5
temp = 0
w = SmartTags("DB400")(j)

If (w And &h10) Then
temp=4 '

Else If (w And &h2) Then


End If

SmartTags("Unit_Status")(j) =temp

End Sub

The SmartTags is a part of another piece of software. The error I am getting is an 'Unexpected Next'. Shouldn't For close with Next?

Thank you - I am not familiar with VB just have to use it as a part of another software.

Answer Source

As written, you have 2 Ifs but 1 End If. So either close the second If

End If
End If

or change it to an ElseIf

ElseIf (w And &h2) Then