To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier

Reply Post New Thread
 
Thread Tools Display Modes
Old Jul 5th, 2007, 12:48 AM   #1
raghunadhs
Addicted Member
 
Join Date: May 07
Posts: 167
raghunadhs is an unknown quantity at this point (<10)
Resolved [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
raghunadhs is offline   Reply With Quote
Old Jul 5th, 2007, 12:56 AM   #2
Paul M
Interweb adm/o/distrator
 
Paul M's Avatar
 
Join Date: Nov 06
Location: Australia, Melbourne
Posts: 2,306
Paul M has a spectacular aura about (150+)Paul M has a spectacular aura about (150+)
Re: can u say how to set the precession as 1 to a "singel" type data type

vb Code:
  1. Dim x As Single
  2. x = 4.01234
  3. MsgBox (Left(x, 1))

Does that help?
__________________
If this post was helpful please rate it
If it wasn't for C, we would be using BASI, PASAL and OBOL.

VB6: [System Uptime] [Extracting WMP Song] [Basic Flood Protection] [RTF Editor]
[Hex/String Conversions] [Reading/Writing INI] [List Files in Directories]


C++: [Mute Audio in Vista]

VB.NET: [Associating a Help File] C#: [One instance of your application]
Paul M is offline   Reply With Quote
Old Jul 5th, 2007, 01:44 AM   #3
opus
I don't do your homework!
 
opus's Avatar
 
Join Date: Jun 00
Location: Good Old Europe
Posts: 2,783
opus has a spectacular aura about (150+)opus has a spectacular aura about (150+)
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!
opus is offline   Reply With Quote
Old Jul 5th, 2007, 01:52 AM   #4
Paul M
Interweb adm/o/distrator
 
Paul M's Avatar
 
Join Date: Nov 06
Location: Australia, Melbourne
Posts: 2,306
Paul M has a spectacular aura about (150+)Paul M has a spectacular aura about (150+)
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.
__________________
If this post was helpful please rate it
If it wasn't for C, we would be using BASI, PASAL and OBOL.

VB6: [System Uptime] [Extracting WMP Song] [Basic Flood Protection] [RTF Editor]
[Hex/String Conversions] [Reading/Writing INI] [List Files in Directories]


C++: [Mute Audio in Vista]

VB.NET: [Associating a Help File] C#: [One instance of your application]
Paul M is offline   Reply With Quote
Old Jul 5th, 2007, 01:58 AM   #5
raghunadhs
Addicted Member
 
Join Date: May 07
Posts: 167
raghunadhs is an unknown quantity at this point (<10)
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






Quote:
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))
raghunadhs is offline   Reply With Quote
Old Jul 6th, 2007, 05:15 AM   #6
westconn1
PowerPoster
 
Join Date: Dec 04
Posts: 13,424
westconn1 is a splendid one to behold (700+)westconn1 is a splendid one to behold (700+)westconn1 is a splendid one to behold (700+)westconn1 is a splendid one to behold (700+)westconn1 is a splendid one to behold (700+)westconn1 is a splendid one to behold (700+)westconn1 is a splendid one to behold (700+)
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:
  1. x = 4.32322
  2. x = Round(x, 1)' one decimal place
  3.  
__________________
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
westconn1 is online now   Reply With Quote
Old Jul 6th, 2007, 12:03 PM   #7
raghunadhs
Addicted Member
 
Join Date: May 07
Posts: 167
raghunadhs is an unknown quantity at this point (<10)
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






Quote:
Originally Posted by westconn1
using the round function you can set to however many decimal places you want

vb Code:
  1. x = 4.32322
  2. x = Round(x, 1)' one decimal place
  3.  
raghunadhs is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic 6 and Earlier


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:37 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.