# Numbers and Strings in Javascript

I am having trouble with Numbers and Strings. Below give me all “NaN”. What is a substitute for Number()?

function Button1_Click(){
var mo = Number(Textbox1.Value);
var dy = Number(Textbox2.Value);
var yr = Number(Textbox3.Value);
var hr = Number(Textbox5.Value);
var mn = Number(Textbox6.Value);
var ampm = Selectbox1.Value;
var tz = Number(Selectbox2.Value);
var dst = Number(Selectbox3.Value);
if ((ampm == “AM”) && (Number(hr) == 12)){
var hr24 = 0;
}
if ((ampm == “AM”) && (Number(hr) < 12)){
var hr24 = Number(hr);
}
if ((ampm == “PM”) && (Number(hr) < 12)){
var hr24 = Number(hr) + 12;
}
if ((ampm == “PM”) && (Number(hr) == 12)){
var hr24 = 12;
}
if (Number(mo) <= 2){
var y = Number(yr) - 1;
var m = Number(mo) + 12;
}else{
var y = Number(yr);
var m = Number(mo);
}
var Bjd = Math.floor(Number(y) / 400) - Math.floor(Number(y) / 100);
var JD0 = Math.floor(365.25 * (Number(y) + 4716)) + Math.floor(30.6001 * (Number(m) + 1)) + Number(Bjd) + -1522.5 + Number(dy);
var JD = Number(JD0) + (Number(hr24) + Number(mn) / 60 - (Number(tz) + Number(dst))) / 24;
var J = (Number(JD) - 2451545) / 36525;
var d2000 = (Number(JD) - 2451545);
var J0 = (Number(JD0) - 2451545)/36525;
var d0 = (Number(JD0) - 2451545);
var d02000 = (Number(JD0) - 2451545);
var JDlocal = (Number(JD0) + (Number(hr24) + Number(mn) / 60));
var Jlocal = (Number(JDlocal) - 2451545);
var d2000local = (Number(JDlocal) - 2451545);
}

Well, what inputs are you feeding them? I have a feeling they’re not the value you expect.

To clarify

``````Number(Textbox1.Value)
``````

You say that this is giving you `NaN`, so I think you should check the value of `Textbox1.Value`. I suspect that it’s `undefined`.

Textbox1.value and Selectbox1.value are my inputs and outputs. They are strings. the var Jlocal are Strings or Floats or numbers.

The property is `value` not `Value` (lower case v)

``````console.log(Textbox1.Value);