|
-
Jul 5th, 2007, 12:48 AM
#1
Thread Starter
Addicted Member
[RESOLVED] can u say how to set the precession as 1 to a "singel" type data type
Hi all!
i want to set the precession of a "single" variable to 1.. is is possible in v.b 6.0? if so , kindly tell me.
egg:
dim x as single
x=4.01234
msgbox(x) ' x shole be 4.0 only ......not 4.01234
so i want to round this.. how it is possible.......
thanks in advance
regards:
raghunadhs
-
Jul 5th, 2007, 12:56 AM
#2
Re: can u say how to set the precession as 1 to a "singel" type data type
vb Code:
Dim x As Single
x = 4.01234
MsgBox (Left(x, 1))
Does that help?
-
Jul 5th, 2007, 01:44 AM
#3
Re: can u say how to set the precession as 1 to a "singel" type data type
Hell-Lord, your suggestion would only work on numbers less then 10. I'd use:
Code:
Dim x As Single
x = 4.01234
MsgBox (Int(x))
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!
-
Jul 5th, 2007, 01:52 AM
#4
Re: can u say how to set the precession as 1 to a "singel" type data type
Yes >.< should have thought of that thanks.
Also probably use CInt instead of Int but yea much better.
-
Jul 5th, 2007, 01:58 AM
#5
Thread Starter
Addicted Member
Re: can u say how to set the precession as 1 to a "singel" type data type
Thanks to all who replied to my question...........
Thanks for your immediate correspondence...
Regards:
raghunads.v
 Originally Posted by opus
Hell-Lord, your suggestion would only work on numbers less then 10. I'd use:
Code:
Dim x As Single
x = 4.01234
MsgBox (Int(x))
-
Jul 6th, 2007, 05:15 AM
#6
Re: can u say how to set the precession as 1 to a "singel" type data type
using the round function you can set to however many decimal places you want
vb Code:
x = 4.32322
x = Round(x, 1)' one decimal place
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 6th, 2007, 12:03 PM
#7
Thread Starter
Addicted Member
Re: can u say how to set the precession as 1 to a "singel" type data type
Hai WestConn1!
I want this type of function only.. thank u very much..
regards:
raghuandhs
 Originally Posted by westconn1
using the round function you can set to however many decimal places you want
vb Code:
x = 4.32322
x = Round(x, 1)' one decimal place
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
|