我有两个文本框TextBox1的和TextBox2中如何解决这个查询?
如果textbox1.Text
大于textbox2.Text
然后textbox2.Text=textbox2.Text
否则,如果textbox1.Text
小于textbox2.Text
然后textbox2.Text
是原样保留....
该怎么做....
我有两个文本框TextBox1的和TextBox2中如何解决这个查询?
如果textbox1.Text
大于textbox2.Text
然后textbox2.Text=textbox2.Text
否则,如果textbox1.Text
小于textbox2.Text
然后textbox2.Text
是原样保留....
该怎么做....
你是否期待整数文本框中的值?然而
itext1 = convert.ToInt32(Textbox1.text)
itext2 = convert.ToInt32(Textbox2.text)
if (itext1 < itext2) then
Textbox1.text=Textbox2.text ' See above comment
主要试试这个方法,如果你也就是比较两个字符串文本字符串:String.Compare Method (String, String, Boolean)
通过使用三元操作?
这样做:
textbox2.Text= textbox1.Text > textbox2.Text ? textbox1.Text:textbox2.Text
您可以通过比较字符串使用String.compareTo(String)作为整数函数。
它将返回一个整数,指示哪个字符串具有更大的值。
If textbox1.Text.CompareTo(textbox2.Text) = 1 Then textbox2.Text = textbox1.Text
将是您的问题的解决方案。
你究竟在哪里卡住? – Heinzi 2011-04-04 11:48:37
顺便说一句,'textbox2.text = textbox2.text'没有多大意义... – Heinzi 2011-04-04 11:48:57
我认为你没有意思textbox2.yexy = textbox2.text – BugFinder 2011-04-04 11:49:13