Q:

Error while comparing msgbox with textbox in vba

I am new to VBA. I have created a program in VBA that compares a msgbox value with a textbox value, but the result is not right. I have copied the code below. What have I done wrong on this? Please help me.
Private Sub CommandButton1_Click()

    Dim num As String
    num = Application.InputBox("enter num")
    If TextBox1.Value * num > TextBox2.Value Then
        MsgBox "textbox1 is higher"
    Else
        MsgBox "textbox2 is higher"    
    End If

End Sub

A:

You Need to make sure all values you are getting from the InpoutBox and TextBox are numbers (in my code converted to Long , just to be on the safe side):
Private Sub CommandButton1_Click()

Dim num As Long

' convert the number received from the InputBox to a number (type Long)
num = CLng(Application.InputBox("enter num"))

If CLng(TextBox1.Value) * num > CLng(TextBox2.Value) Then
    MsgBox "textbox1 is higher"
Else
    MsgBox "textbox2 is higher"
End If

End Sub

