Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSTR([FieldName], First Non Numeric Character) 1

Status
Not open for further replies.

rgbanse

MIS
Jun 4, 2001
211
US
Using The Instr Command is there a way to find the position of the first Non-numeric character ie:
123456WWSH
123456FFRM
thx
RGB
 
RGB,

The following evaluates the first string (123456WWSH) as a value in textbox, T1. The value returned in T2 (WWSH) is the portion of the string beginning with the first non-numeric character. Keep in mind that a space or a backslash or whatever is also non-numeric. A string like "1234 567TEST" would return " 567TEST".

Code:
Private Sub Command2_Click()
Dim MyString As String, NewString As String
Dim i As Integer, MyPos As Integer

  MyString = T1

  For i = 1 To Len(MyString)
    If Not IsNumeric(Mid(MyString, i, 1)) Then
       MyPos = i
       Exit For
    End If
  Next i

NewString = Mid(MyString, i)
T2 = NewString

End Sub

HTH



John

Use what you have,
Learn what you can,
Create what you need.
 
Thx John - You got me on the right track
I just gave it a different twist

Function PullWipNumber()
Dim DocNbr As String
Dim WipNbr As String
Dim DocNbrLength As Integer
Dim CountBack As Integer
DocNbr = "1234564wshh/fnl" 'Exmpl of Document Field in table
DocNbrLength = Len(DocNbr)

For CountBack = 1 To DocNbrLength
If IsNumeric(Left(DocNbr, DocNbrLength - CountBack)) Then
WipNbr = Left(DocNbr, DocNbrLength - CountBack)
GoTo WeHaveWipNbr
End If
Next

WeHaveWipNbr:
MsgBox WipNbr
End Function

thx
RGB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top