Sign in to follow this  
Followers 0
ozone

How to tell if string is a digit/letter?

3 posts in this topic

#1 ·  Posted (edited)

GOAL = Convert "00,03,01,001,1,0,0,01,00,00,00,0,HELLO" to an array of either numbers or strings.

$data = StringSplit("00,03,01,001,1,0,0,01,00,00,00,0,HELLO", ",")

But here is the problem.

Number($data[1]) returns 0

Number($data[13]) returns 0

That's a problem... Ideas in how to preserve existing strings?

Edited by ozone

Share this post


Link to post
Share on other sites



GOAL = Convert "00,03,01,001,1,0,0,01,00,00,00,0,HELLO" to an array of either numbers or strings.

$data = StringSplit("00,03,01,001,1,0,0,01,00,00,00,0,HELLO", ",")

But here is the problem.

Number($data[1]) returns 0

Number($data[13]) returns 0

That's a problem... Ideas in how to preserve existing strings?

<{POST_SNAPBACK}>

Ahh, maybe I'm just having a slow day haha. The solution would be:

If StringIsAlNum($data[1])=1 Then $data[1]=Number($data[1])

Share this post


Link to post
Share on other sites

Use the function StringIsDigit

Here is the final result:

$data = StringSplit("00,03,01,001,1,0,0,01,00,00,00,0,HELLO", ",")
For $i = 1 To $date[0]
   If StringIsDigit($data[$i]) Then $data[$i] = Number($data[$i])
Next

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0