Problem when trying to obtain a decimal from an input box
jsandoval
Forums
Hello Everyone,
I'm trying to obtain a decimal number inserted by an input box, but the problem is that IDEA shrinks the number, so if I type 1.9 and store it in a variable, the value of the variable is 1 instead of 1.9. Can anyone help me with this, please?
Hi jsnadoval,
Hi jsnadoval,
Here is how you should set this up. You should also add some error checking to make sure the user doesn't enter something like "ABC" or a blank.
Sub Main
Dim sInputResult As String 'The result from the input box returns a string. The variable to hold it should be a string and then changed into the proper value
Dim t_cambio As Double
sInputResult = InputBox("Escriba el tipo de cambio : ", "Tipo de Cambio", "0.00") 'default amount needs to be a string
t_cambio = CDbl(sInputResult) 'converst the string to a double
MsgBox t_cambio
End Sub
I'm sorry I forgot to attach
I'm sorry I forgot to attach my script. I think the problem is related to the data type when declaring y variable. Does anyone know wich datA Type is the equivalent in IDEA to a float?
Sub Main
Dim t_cambio As Double
t_cambio = InputBox("Escriba el tipo de cambio : ", "Tipo de Cambio",0.00)
MsgBox t_cambio
End Sub