Results 1 to 8 of 8

Thread: VAL function gives rounded integer [SOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160

    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.

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    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.

  3. #3
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    The Big D
    Posts
    310

    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

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160
    Hi
    thanks for your quick reply, but I had set Integer and also Long but the same result !!!

    thanks again

  5. #5
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863
    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!

  6. #6
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068
    Will cInt(0.5) not fix this?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2003
    Posts
    160
    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

  8. #8
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    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
  •  



Click Here to Expand Forum to Full Width