|
-
Oct 12th, 2003, 05:21 AM
#1
Thread Starter
Addicted Member
VAL function gives rounded integer [SOLVED]
hi
I got here a text box which hold an integer with decimals but when I try to retrieve it and convert it into integer value it will round it automatically, and I'm pissed off to fixed it even CDbl will give rounded...
here
text1.text = ".5"
b = text1.text
c = Val(b)
msgbox c '<<<will show Zero !!!!
any help is highly appreciated
S. Mohammad Najafi
Last edited by vbcodec; Oct 12th, 2003 at 12:04 PM.
-
Oct 12th, 2003, 06:41 AM
#2
PowerPoster
val(.5) will give you .5
int (.5) will give you 0
all this is as it should be. if you don't understand, you should read the on-line help regarding data types.
-
Oct 12th, 2003, 08:03 AM
#3
Hyperactive Member
Re: VAL function gives rounded integer [Urgent]
What datatype is c?
Originally posted by vbcodec
hi
I got here a text box which hold an integer with decimals but when I try to retrieve it and convert it into integer value it will round it automatically, and I'm pissed off to fixed it even CDbl will give rounded...
here
text1.text = ".5"
b = text1.text
c = Val(b)
msgbox c '<<<will show Zero !!!!
any help is highly appreciated
S. Mohammad Najafi
-
Oct 12th, 2003, 09:27 AM
#4
Thread Starter
Addicted Member
Hi
thanks for your quick reply, but I had set Integer and also Long but the same result !!!
thanks again
-
Oct 12th, 2003, 09:42 AM
#5
Try using a C dimmed as Single!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Oct 12th, 2003, 10:39 AM
#6
Frenzied Member
Will cInt(0.5) not fix this?
-
Oct 12th, 2003, 10:56 AM
#7
Thread Starter
Addicted Member
thanks alot
I had to choose single or double, I found out that Integer or Long have the default decimal value to zero.... it was good to know new things
thanks again.
S. mohammad Najafi
-
Oct 12th, 2003, 02:20 PM
#8
So Unbanned
Originally posted by vbcodec
thanks alot
I had to choose single or double, I found out that Integer or Long have the default decimal value to zero.... it was good to know new things
thanks again.
S. mohammad Najafi
Types Byte, Integer, ang Long do not support decimals.
Single, Double, Decimal, and Currency do.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|