RSS Forums RSS
Please support our VB.NET advertiser: Programming Forums

LEFT syntax

Join Date: Apr 2007
Posts: 5
Reputation: Albert88 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Albert88 Albert88 is offline Offline
Newbie Poster

Help Re: LEFT syntax

  #3  
Apr 28th, 2007
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
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 1:08 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC