Results 1 to 6 of 6

Thread: Help with numbers

  1. #1

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287

    Help with numbers

    Hey,
    I have a function that returns numbers. It can returns integer numbers (1,2,5) or numbers like 1.5, 8.5 0.5. Only These kind of numbers. The numbers represents hours.
    Now i need to know if the number has values after the dot. It can be only 5 (x.5), but then i know its not a complete hour.
    How can I check if the number is a complete hour or not?
    Thanks

  2. #2
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: Help with numbers

    If Int(Number) = Number Then ' The number is an integer

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Help with numbers

    Would this work for you?
    Code:
    Private Sub Command1_Click()
    Dim SomeNumber As Single
    
        SomeNumber = 12.5
        
        If SomeNumber - Fix(SomeNumber) = 0 Then
            MsgBox "It's a whole number."
        Else
            MsgBox "Number contains decimals."
        End If
    
    End Sub

  4. #4

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287

    Re: Help with numbers

    The first code of Logophobic works fine.
    Now I have another problem, with my database. I dont want to open a new thread though.
    I need to know if a record set in my table is empty. I have this:
    Code:
    If RS("Comment") = vbNull Then
        MsgBox "Null"
    Else
        MsgBox "Value"
    End If
    Even when the record has a value, it will msgbox Value. How can i get it right?

  5. #5

  6. #6

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