# function to see if a word has a number in it

I need to see if a word has any numerals in it:

"String!"= false
"string12" = true
"1245" =true
"1245six"=true
"str13str"=true

not sure how to do that part

I can grab the strings and split them and put them into an array

not sure how to achieve the function.
am in vba
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
? (" " & "asd1" & " ") like "*[1-9]*"
0
Author Commented:
i need to test within a for loop in vba

for the second word in the wordarray(index)

check if word has numerals
if yes out true

next wordarray
0
Author Commented:
hence need of a function
0
Commented:
dim j as integer
for j=1 to len(wordarray(index))
if isnumeric(mid(wordarray(index),j,1)) then
numberexists=true
exit for
end if
next
0
Commented:
Rey,

he didn't say he wanted to know whether it isNumeric() the OP stated "I need to see if a word has any numerals in it", with examples of:

"String!"= false
"string12" = true

Peter, since you done describe the for loop criteria, here is an example

For intloop = 1 to intSomething

If WordArray(1) LIKE "*[0-9]*" Then
'do something here
Endif

Next
0
Commented:
Dale,
better read the codes I posted carefully..
0
Commented:
My bad, thought you were looping through his array.

Still, way more cumbersome than a simple Like comparison.

Dale
0
Commented:
Or you can use regular expressions:
``````Sub Demo()
Dim strArray() As String
Dim i As Integer

strArray = Split("String! string12 1245 1245six str13str", " ")

For i = LBound(strArray) To UBound(strArray)
If fContainsNumerals(strArray(i)) Then
MsgBox "Array element " & i & ": " & strArray(i) & " contains numerals!"
Else
MsgBox "Array element " & i & ": " & strArray(i) & " doesn't contains numerals!"
End If
Next
End Sub

Function fContainsNumerals(ByVal strInput As String) As Variant

With CreateObject("VbScript.RegExp")
.Global = True
.Pattern = "[^\D]"
fContainsNumerals = .test(strInput)
End With

End Function
``````
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
ok guys i have shared the points hope that remains acceptable.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.