I need to create a form with 2 text boxes to receive numbers as input and 1 command button that displays a message box containing the larger of the two numbers. To do so, I need to write code in the Click event of the command to call a user-defined function named FindLargestNumber. Pass it 2 arguments(textboxvalues) and display the result in a message box. Write code in the FindLargestNumber function to determine the larger number and return result to the calling procedure(command button Click event).
The code is working, but when I enter in two numbers, only the first character of each string of numbers is compared. What happends is when I compare "667" and "7", "7" is returned as the highest number. I can't figure out what's wrong. Please help!!
Option Compare Database Dim number1 As Double Dim number2 As Double Private Sub cmd1_Click() MsgBox "The largest number is " & FindLargestNumber(Me.text1, Me.text2) End Sub Public Function FindLargestNumber(number1, number2) As Integer If number1 > number2 Then FindLargestNumber = number1 ElseIf number2 > number1 Then FindLargestNumber = number2 End If End Function