i still got the error on my program. the error is in red color font, it say that "Index and length must refer to a location within the string."
what it does mean? and can you check my coding. i want to validate the order number. the order number must be started with "SO" and then followed with 3 or 5 number. is the coding correct?
Thanks
Dim strOrderNo As String = ValidateOrderNumber(txtOrderNumber.Text)
If strOrderNo = "invalid" Then
MessageBox.Show("Error: Invalid Order Number")
With txtOrderNumber
.SelectAll()
.Focus()
End With
Return
End If
Private Function ValidateOrderNumber(ByRef strOrderNo As String) As String
strOrderNo = strOrderNo.ToUpper
If Not (Len(strOrderNo) >= 5 And Len(strOrderNo) <= 7) Then
Return "invalid"
End If
If Not (strOrderNo.Substring(0, 2)) = "SO" Then
Return "invalid"
End If
If Not (IsNumeric(strOrderNo.Substring(2, 5)) Or _
IsNumeric(strOrderNo.Substring(2, 7))) Then
Return "invalid"
End If
Return strOrderNo
End Function