 |
|
|
|
| Author |
Message |
Carlos Villaseņor M.
Joined: 04 Oct 2007 Posts: 7
|
Posted: Wed Jul 26, 2006 5:53 am Post subject: VB6: How can I to convert text control value to a numeric va |
|
|
Hi everybody!
I tried to using a text control and I need to use its numeric value, first I
need to know wich function can converts a numeric text value to integer
and/or decimal. I tried to use n=CInt(Val(textControl.text)), but appears
the error number 6 (overflow error).
I appreciate some help.
Thank you
Carlos Villaseņor M.
Archived from group: microsoft>public>vb>syntax |
|
| Back to top |
|
 |
Jan Hyde
Joined: 04 Oct 2007 Posts: 1211
|
Posted: Wed Jul 26, 2006 1:07 pm Post subject: Re: VB6: How can I to convert text control value to a numeri |
|
|
"Carlos Villaseņor M." 's wild
thoughts were released on Wed, 26 Jul 2006 01:53:53 -0500
bearing the following fruit:
>Hi everybody!
>
>I tried to using a text control and I need to use its numeric value, first I
>need to know wich function can converts a numeric text value to integer
>and/or decimal. I tried to use n=CInt(Val(textControl.text)), but appears
>the error number 6 (overflow error).
>
please do not Mulipost - please read up on what multiposting
is and you'll see why you should not do it.
Jan Hyde (VB MVP)
--
Realize: Those you can see with. (Stan Kegel) |
|
| Back to top |
|
 |
HKSHK
Joined: 04 Oct 2007 Posts: 12
|
Posted: Wed Jul 26, 2006 6:14 pm Post subject: Re: VB6: How can I to convert text control value to a numeri |
|
|
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
|
|
| Back to top |
|
 |
|
|
| Related Topics: | How To Strip Out Non Alpha/Numeric Characters From A String Hi, I need to take phone number field values and just extract the numbers and ignore dashes, slashes, periods, parenthesis, and what ever else people enter into these fields. For that matter, it would be handy to be able to extract numbers and/or letters
How do you hold on to leading zeros in Numeric fields? I am pulling a series of numbers from a local database and I want to use them to qualify a query to the mainframe by writing them to a data set. The mainframe wants the fields to be char(3), which means I need the leading zeros added to the result of th
Convert expresion to vb,vba functions Hi all! Im creating Default Value property for activeX TextBox. I would like that this Default Value property could also convert string expresion like Now()or Date() to function Now or Date . '* Public Property Get As String DefaultValue =
convert byte to string Hello I have the following : dim s as string dim b as byte b has a value of 97 (ordinal value of character "a" ) How can "s" get the value from b ? Thanks :)
POINT Command from VB 6 Won't Convert to VB .NET I created a program using VB 6 that included several lines of code checking a point for color. Generally, the lines looked like this: IF POINT(X, Y) = &HFFOOFF THEN operations END IF where X and Y were the X and Y coordinates of the point, &HFFOOFF was th |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|