Alpha Video Training
Results 1 to 3 of 3

Thread: Equivalent of Round Function in Xbasic?

  1. #1
    "Certified" Alphaholic
    Real Name
    Jetson Lilibeth
    Join Date
    Dec 2011
    Posts
    1,093

    Default Equivalent of Round Function in Xbasic?

    Here is a round function created in visual basic. How do we do this in Xbasic?Thanks!

    Public Function RoundExt( _
    ByVal dblNumber As Double, _
    ByVal intDecimals As Integer) _
    As Double
    ' Comments : Rounds a number to a specified number of decimal
    ' places (0.5 is rounded up). Unlike the VB 6 Round
    ' function, this one works correctly.
    ' Parameters: dblNumber - number to round
    ' intDecimals - number of decimal places to round to
    ' (positive for right of decimal, negative for left)
    ' Returns : Rounded number
    '

    Dim dblFactor As Double
    Dim dblTemp As Double

    On Error GoTo PROC_ERR

    dblFactor = 10 ^ intDecimals
    dblTemp = dblNumber * dblFactor + 0.5
    RoundExt = Int(CDec(dblTemp)) / dblFactor

    PROC_EXIT:
    Exit Function

    PROC_ERR:
    MsgBox "Error: " & err.Number & ". " & err.Description, , _
    "RoundExt"
    Resume PROC_EXIT

    End Function

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Equivalent of Round Function in Xbasic?

    Are you sayiing Alpha's round function is flawed?

    http://wiki.alphasoftware.com/ROUND+Function
    There can be only one.

  3. #3
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    6,026

    Default Re: Equivalent of Round Function in Xbasic?

    I think without looking up:

    Round()
    round_down()
    round_up()

    They are already written for you.
    If you go back to v7, round down did not work so I rewrote it and it is in the code archive.
    Dave Mason
    dave@aldausa.com
    Skype is dave.mason46

Similar Threads

  1. How do I Round a number in XBasic?
    By Easy Rider in forum Application Server Version 9 - Web/Browser Applications
    Replies: 3
    Last Post: 11-26-2008, 08:41 PM
  2. xbasic function equivalent to SQL statement
    By slamdunk in forum Alpha Five Version 8
    Replies: 4
    Last Post: 11-01-2007, 09:12 AM
  3. Xbasic 'Chain' equivalent
    By NormMike in forum Alpha Five Version 8
    Replies: 3
    Last Post: 04-21-2007, 12:32 PM
  4. Round Down Function
    By ChrisHawkes in forum Archived Wishlist
    Replies: 9
    Last Post: 04-04-2006, 06:14 PM
  5. Round Function
    By WillieLucas in forum Alpha Five Version 4
    Replies: 6
    Last Post: 04-06-2002, 01:59 PM

Bookmarks

Posting Permissions

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