I have the following code, comments detail what should happen:
averageNum = myArray2(0) 'assign variable
response.write(TypeName(averageNum)&"<br>") 'check var type: string as expected
averageNum = CInt(averageNum) 'convert to integer
When I run this is I get
Type mismatch: 'CInt'
I need to turn the variable into an integer as I need to perform calculations with it
I would be checking that the value of
myArray2(0)
is an integer as you're expecting. Simple way to do this is usingIsNumeric()
which returns aBoolean
value.Something like this;