# Convert input box entry to a number/integer

**URL:** <https://forum.kirupa.com/t/convert-input-box-entry-to-a-number-integer/240940>\
**Category:** flash\
**Created:** [October 8, 2007, 3:09pm UTC](https://forum.kirupa.com/t/convert-input-box-entry-to-a-number-integer/240940 "2007-10-08T15:09:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![terrapods](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@terrapods](https://forum.kirupa.com/u/terrapods)\
**Post date:** [October 8, 2007, 3:09pm UTC](https://forum.kirupa.com/t/convert-input-box-entry-to-a-number-integer/240940/1 "2007-10-08T15:09:25Z")

</div>

I have an input box which I enter a numerical value into, I want to compare this value with a variable (\_total), but beause its a string it won’t compare it to a number value, I’ve tried varius things including parseInt() but I can’t seem to get it to work. Any ideas? Code so far below:

Thanks

var \_total:Number = new Number()  
var myAnswer:TextField = new TextField();  
myAnswer.type = TextFieldType.INPUT;  
myAnswer.maxChars = 2;  
myAnswer.restrict = “0-9”;

function onClick(event:MouseEvent):void {

```
myAnswer.text = Number(myAnswer1);

if (MyAnswer == (_total)) {
    trace("Correct!");
} else {
    trace("Wrong!");
}

```

}
