-1
Waht对此有错? 我有一个简单的形式与textbox1和textbox2和一个按钮。 当我把Textbox1 = 259和textbox2 = 1500 我点击,他说“你的号码太高” 我试试151“你的号码太高” 我试试150“ok” 我试试1500 “OK” 我尝试1501 “你数太高”vb net +检查Textbox1是否<Texbox2
帮助.........
Public Class test
Private Sub test_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text > TextBox2.Text = True Then
MsgBox("You're number is too high")
Else
MsgBox("ok")
End If
End Sub
末级
是你要比较的数值或字符串,看起来像数字时使用瓦尔(串)的功能。如果它是前者将字符串转换为数字并进行比较。还要除去If上的True。 – dbasnett
您正在比较字符串。 “259”确实大于“1500”,“2”在“1”之后排序。 Val()和CDec()可用于进行转换。但考虑Decimal.TryParse(),还可以帮助您检查用户是否实际输入了一个数字,而不是“asdf”或根本没有。 –