Convert numbers to text

# Thread: Convert numbers to text

1. Senior Member
Join Date
Dec 1969
Posts
252

## Convert numbers to text

Hi,<BR><BR>Does anyone know of a function that will convert a numeric value into its text equivalent?<BR><BR>i.e. 1 to one, 2 to two etc<BR><BR>Thanks,<BR><BR>Martin

2. Senior Member
Join Date
Dec 1969
Posts
503

## There isn't one <eop>

.

3. Senior Member
Join Date
Dec 1969
Posts
905

## RE: There isn't one <eop>

.

4. Senior Member
Join Date
Dec 1969
Posts
905

## Apparently I'm an idiot

5. Senior Member
Join Date
Dec 1969
Posts
905

## Even more stupid

Do you mean convert 1, 2, 3 into &#039;one&#039;, &#039;two&#039;, &#039;three&#039;<BR><BR>If so toozious is right there isnt one.<BR><BR>God I need coffee

6. Senior Member
Join Date
Dec 1969
Posts
503

## hahah! :-)

.

7. Senior Member
Join Date
Dec 1969
Posts
358

## RE: Convert numbers to text

Create your own.<BR><BR>Write the script (a set of if statements or case statements)<BR>set it as a function ,i.e:<BR><BR>Function change(x)<BR>if x = "1" then<BR> x = "One"<BR>end if<BR>end function<BR><BR>number = change(number)<BR><BR>use it as an include file on any page you want to use it on.<BR>Call the function in the page.<BR>

8. Senior Member
Join Date
Dec 1969
Posts
905

## That could get messy

It depends of course on the numbers range you would be using. It would be fairly straighforward if your using 0-9 but when you start using numbers like 15, 206, 1890, 10987 etc... this wouldn&#039;t be as simple.<BR><BR>You would have to get the length of the number as a string and apply a set of rules to govern what value each number was in the string and the value it had. eg is one, one hundred, one thousand.<BR><BR>It is possible but not as simple as suggested.<BR><BR>Matt

9. Senior Member
Join Date
Dec 1969
Posts
358

## So it could...

But the principle is sound.<BR><BR>Like you suggested though, getting the length of the string & applying a set of rules is easy to do, within reason (less than 1 million).<BR>

10. Join Date
Dec 1969
Posts
86

## RE: hahah! :-)

If someone hasn&#039;t written a function that does this (at least up to 100), why not? Surely its a useful thing which is done once and shared with the community?<BR>Maybe instead of how many decimal places we can get out of pi, we should be looking at how far we can extend the following code:<BR><BR>Select Case intNumber<BR>Case 1<BR>strNumber = "one"<BR>Case 2<BR>strNumber = "two"<BR>Case 3<BR>strNumber = "three"<BR>Case 4<BR>strNumber = "four"<BR>...etc etc...<BR>End Select<BR><BR>Maybe those guys at SETI will lend us the support of the "FindAnAlien" screensaver when ET finally arrives :-)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•