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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another string queston

Status
Not open for further replies.

sborny

Technical User
Jun 29, 2001
157
0
0
GB
Hi all,

I need to check a string to see if it starts with a number ie: a house number like 62 George Close. If it does iwant to extract that number into a seperate string and if not I need to do something else.

I know what i need to do if the string does not contain a number but I canot work out how to check for a number at the beginning of the string.

Thanks

S.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
Try

Dim items: items = Split(Text1.Text, " ")
If IsNumeric(items(0)) Then
MsgBox ("Yes")
End If

This splits the textbox into parts seperated by a space and sees if the first part is numeric.

Note: This will fail on 12a Geaorge Street
 
Hi shatch,

Thanks for that. Do you have any ideas on how to get round the 12a thing as it is a very distinct possibility that that will happen.

Cheers

S.


Everything has an answer, it's just knowing the right question to ask. !!!!
 
Sure, i can help with that,

Dim items: items = Split(Text1.Text, " ")
If IsNumeric(items(0)) Or IsNumeric(Left(items(0), Len(items(0)) - 1)) Then
MsgBox ("Yes")
End If

 
If Val(Text1.Text) > 0 Then
' it starts with a number

Then do your split (or whatever)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top