# How to tell if string is a digit/letter?

## Recommended Posts

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 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 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```

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...