I need to split a string into its alpha and numeric components. The text will look something like "EMPU123456" with the first 3 or 4 characters being alpha and the rest being numeric. For those of you curious these are thepiggyback semi-trailer numbers you see loaded on rail cars. The following code works, just wondering if there's a more efficient method? I know. I could start at the 4th character, but left it at one for testing purposes.
[code/]
Dim ColNo As Integer
Dim NumColNo As Integer = 0
Dim cTrlrAlpha As String = ""
Dim cTrlrNum As String = ""
For ColNo = 1 To txtTrailerNo.Text.Length
NumColNo = InStr(1, "01234567890", Mid(txtTrailerNo.Text, ColNo, 1).ToString)
If NumColNo > 0 Then
cTrlrAlpha = Mid(txtTrailerNo.Text, 1, ColNo - 1).ToString.Trim
cTrlrNum = Mid(txtTrailerNo.Text, ColNo).ToString.Trim
Exit For
End If
Next
[/code]
Auguy
Sylvania, Ohio
[code/]
Dim ColNo As Integer
Dim NumColNo As Integer = 0
Dim cTrlrAlpha As String = ""
Dim cTrlrNum As String = ""
For ColNo = 1 To txtTrailerNo.Text.Length
NumColNo = InStr(1, "01234567890", Mid(txtTrailerNo.Text, ColNo, 1).ToString)
If NumColNo > 0 Then
cTrlrAlpha = Mid(txtTrailerNo.Text, 1, ColNo - 1).ToString.Trim
cTrlrNum = Mid(txtTrailerNo.Text, ColNo).ToString.Trim
Exit For
End If
Next
[/code]
Auguy
Sylvania, Ohio