Re: VB6: How can I to convert text control value to a numeric value?
- From: HKSHK <hkshk@xxxxxxx>
- Date: Wed, 26 Jul 2006 14:14:38 +0200
Hello Carlos,
and/or decimal. I tried to use n=CInt(Val(textControl.text)), but appears
the error number 6 (overflow error).
This error 6 (overflow) means that the number is too large for that variable.
From the Help files:
Byte 1 byte 0 to 255
Boolean 2 bytes True or False
Integer 2 bytes -32,768 to 32,767
Long 4 bytes -2,147,483,648 to 2,147,483,647
Single 4 bytes -3.402823E38 to -1.401298E-45 for
negative values;
1.401298E-45 to 3.402823E38 for positive
values
Double 8 bytes -1.79769313486232E308 to
-4.94065645841247E-324 for negative
values;
4.94065645841247E-324 to
1.79769313486232E308 for positive values
Currency 8 bytes -922,337,203,685,477.5808 to
922,337,203,685,477.5807
Decimal 14 bytes +/-79,228,162,514,264,337,593,543,950,335
with no decimal point;
+/-7.9228162514264337593543950335 with
28 places to the right of the decimal;
smallest non-zero number is
+/-0.0000000000000000000000000001
So, If your variable is an integer, then the maximium value is 32767. If you have a value of let's say 40000, then you receive an overflow error.
For converting numbers, please use one of these functions:
CBool(expression)
CByte(expression)
CCur(expression)
CDbl(expression)
CDec(expression)
CInt(expression)
CLng(expression)
CSng(expression)
So, if you want to convert a long variable, then you would do it like this:
MyLong = CLng(Text1.Text)
The construct "CInt(Val(...))" is not necessary. Val returns the number as well as CInt does.
Best Regards,
HKSHK
.
- References:
- VB6: How can I to convert text control value to a numeric value?
- From: Carlos Villaseņor M.
- VB6: How can I to convert text control value to a numeric value?
- Prev by Date: Re: VB6: How can I to convert text control value to a numeric value?
- Next by Date: Re: Array problems
- Previous by thread: Re: VB6: How can I to convert text control value to a numeric value?
- Next by thread: Re: Array problems
- Index(es):