[Gambas-user] More help with converting
Benoît Minisini
gambas at ...1...
Sat Feb 8 22:25:27 CET 2003
Le Samedi 8 Février 2003 18:59, Joseph Montanez a écrit :
> Ok So I think I know how to convert from numbers to letters but I am having
> problems becuase I convert letters into numbers then back into letters
> (interger and strings). Now I can gt a user to enter number and display
> then as intergers in a textbox, but when I try adding the convert numbers
> to the class I make:
>
> mathvaribles(x,y) "and I set each textbox up as like x1, x2, y1 ect"
> eq1 = mathvaribles(x1,y1)
> The I try to print eq1 into a textbox, then I i gotta convert it,
> eq1 = IsNull(Str$(eq1))
> Now I amready did public declaring and the instant constructor thing (i
> think I did it right) yet when i run it, it gives me "-1" Can anyone help
> me?
>
> http://xingo.filetap.com/Domyhomework <--- the director in which the files
> are in please look at them
>
Hi Joseph,
You got totally confused ! :-)
IsNull() returns a boolean. It tells if its argument is NULL or not. If you
store its result in an integer variable, the boolean is implicitely converted
into 0 or -1. So your result !
To put the TextBox contents into a integer variable, do :
DIM v AS Variant
v = Val(hTextBox.Text)
if IsNull(v) then goto _ERROR ' This is not a number
To transform a number into a string, use Str$() if you have used Val(), or
CStr() if you have used CInt().
You can use the TRY instruction to catch error in these convertion functions.
Regards,
--
Benoît Minisini
mailto:gambas at ...1...
More information about the User
mailing list