' Basic Programming
' Ch. 6 Demo Program #8
' by Mr. Minich
' purpose - to illustrate the use of a general function to round a number

Option Explicit

Private Sub cmdCompute_Click()
   Dim sngUserInput As Single

   sngUserInput = Val(txtInput.Text)
   lblOutput.Caption = "The rounded number is " & intRound(sngUserInput)
End Sub

Private Function intRound(sngNum As Single) As Integer
   intRound = Int(sngNum + 0.5)
End Function

' The built-in VB Int function is used in this program to truncate a positive integer.
' For example, Int(3.4) = 3 while Int(3.9) = 3 also

' There is a built-in VB function named Round that can be used to round a number.
'    But isn't this algorithm more exciting?