Results 1 to 3 of 3

Thread: How would I

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344
    Divide, 2/11....... after i get the answer 5.5 how would i get the 5 after the .?
    -RaY
    VB .Net 2010 (Ultimate)

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'there must be a math function for this but I don't have
    'msdn available and you are using VB3 so I don't even know
    'if you have access to the InStr/cSng Functions.
    
    
    Private Sub Form_Load()
    
    'I assume there are better ways but this will work
    'if using decimals you must be using single/double/long
    'x = result of your division
    
        Dim x As Single
        x = 5.5
        
        Dim SearchString, SearchChar, MyPos
    'convert it to a string
        SearchString = CStr(x)
    'search for the .
        SearchChar = "."
        MyPos = InStr(1, SearchString, SearchChar, 1)
    
    'if found MyPos will be > 0
        If MyPos > 0 Then
    'trim away all but what follows the .
            SearchString = Right(SearchString, Len(SearchString) - MyPos)
    'switch back to single
            x = CSng(SearchString)
            MsgBox x  'value of x as a single
        End If
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Lively Member
    Join Date
    Aug 2000
    Location
    Ontario, Canada
    Posts
    79
    Not sure if this works for everything, but you can try it out:

    Code:
        Dim x As Single
    
        x = (11 / 2 - 11 \ 2)
        MsgBox (x)

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