# Converting from a string to a numeric

**URL:** <https://forum.kirupa.com/t/converting-from-a-string-to-a-numeric/12931>\
**Category:** flash\
**Created:** [February 6, 2003, 8:33am UTC](https://forum.kirupa.com/t/converting-from-a-string-to-a-numeric/12931 "2003-02-06T08:33:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveD](https://avatars.discourse-cdn.com/v4/letter/s/c4cdca/32.png) [@SteveD](https://forum.kirupa.com/u/SteveD)\
**Post date:** [February 6, 2003, 8:33am UTC](https://forum.kirupa.com/t/converting-from-a-string-to-a-numeric/12931/1 "2003-02-06T08:33:48Z")

</div>

Hi,  
I have an mc.instance name is **Twentysecond**  
it has a text box called **label**  
When clicked Twentysecond populates a text box and I want to use this code  
Flash will not let me use an instance name of 22nd.

TwentySecond.label = \_name;//(I want this to show 22)

onRelease = function(){  
myTextBox = \_name; // (I want this to show 22nd  
}

I should know how to do this, but memory is failing, hoping some kindly soul can jog it along for me.  
Any help appreciated

Cheers

SteveD

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2003, 8:36am UTC](https://forum.kirupa.com/t/converting-from-a-string-to-a-numeric/12931/2 "2003-02-06T08:36:40Z")

</div>

I don’t understand what’s happening :-\ And what SHOULD happen :sleep: Can you explain where you put your codes?[SIZE=1]■■■■ Frenchmen…[/SIZE]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2003, 8:52am UTC](https://forum.kirupa.com/t/converting-from-a-string-to-a-numeric/12931/3 "2003-02-06T08:52:49Z")

</div>

Hi ilyaslamasse,  
When I re - read that post - neither did I understand it (lol!!!) well it is early here !  
Anyways, I am halfway there myself, I had made a basic typo and discovered that I can give my instance a name of **22nd**  
What I need is the correct syntax for indexOf. so that I can remove the **nd**  
Do you know that ilya ? does anyone else ?

Cheers

StevD

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2003, 1:07pm UTC](https://forum.kirupa.com/t/converting-from-a-string-to-a-numeric/12931/4 "2003-02-06T13:07:02Z")

</div>

C’est dans la doc :trout:

String.indexOf(“taStringQueTuCherches”);

pom :crazy:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 6, 2003, 1:58pm UTC](https://forum.kirupa.com/t/converting-from-a-string-to-a-numeric/12931/5 "2003-02-06T13:58:35Z")

</div>

Hi,  
OK, I got it eventually, a beter description is that I have 31 mc’s representing the days of the month, they are called 1st 2nd 3rd and so on until…31st  
What I needed to do was strip out the letters after the numbers so that they appeared in a text box ( label) as 1 2 3 4 and so on  
The objective being to use as little AS as possible - this what I came up with for those of you that are following this thread

if(!\_name.substr(0,2)){  
this.label = \_name.substr(0, 1);  
} else {  
this.label = \_name.substr(0, 2);  
}

It works perfectly

Cheers

SteveD
