hurry!!!!help plz !about visual basic!!?

2008-01-14 9:03 am
hurry !!!help!!!about visual basic!!!
what's the code to find the bigger number of the two text boxes????????hurry

i tried this one,but cannot :


Private Sub CommandButton1_Click()
If textbox1 > textbox2 then
Msgbox textbox2 + “ is bigger “
Else if textbox2 > textbox1 then Msgbox textbox1 + “ is smaller “
Else
Msgbox “both the numbers are equal”
End if
End sub

is there any error???????
更新1:

actually user faster's code works,,but it doesn't show like example: 2 and 1 "2 is bigger" somth like that

更新2:

plz help me

回答 (4)

2008-01-14 9:39 am
✔ 最佳答案
Looks like VB 6 not VB.NET code so you use Val() function

Private Sub CommandButton1_Click()
If Val(textbox1.text) > Val(textbox2.text) then
Msgbox Val(textbox2.text) + “ is bigger “
Else if Val(textbox2.text) > Val(textbox1.text) then Msgbox Val(textbox1.text) + “ is smaller “
Else
Msgbox “both the numbers are equal”
End if
End sub
2016-04-05 2:26 pm
You are looking for the GotFocus event.
2008-01-14 9:27 am
If (Convert.ToInt32((TextBox1.Text)) > (Convert.ToInt32((TextBox2.Text)))) Then
MsgBox("Text1 is greater", MsgBoxStyle.Information, "Title")
Else
MsgBox("Text2 is greater", MsgBoxStyle.Information, "Title")

End If
2008-01-14 9:25 am
Private Sub CommandButton1_Click()
if textbox1 > textbox2 then
Msgbox "textbox 1 is bigger than textbox 2", vbInformation, "Info"

else:
if textbox2 > textbox1 then
Msgbox "textbox 2 is bigger than textbox 1", vbInformation, "Info"
else:
Msgbox "both numbers are equal", vbInformation, "Info"
end if
end if

end sub


收錄日期: 2021-05-01 00:55:07
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080114010345AAIGeqE

檢視 Wayback Machine 備份