Results 1 to 7 of 7

Thread: [RESOLVED] can u say how to set the precession as 1 to a "singel" type data type

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    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

  2. #2
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    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?

  3. #3
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    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!

  4. #4
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    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.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    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))

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
    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

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width