开发者

how to solve this query?

I have two textbox textbox1 and textbox2

if textbox1.Text is greater than textbox2.Text the开发者_如何转开发n textbox2.Text=textbox2.Text

else if textbox1.Text is smaller than textbox2.Text then textbox2.Text is remains as it is ....

how to do that ....


You can compare Strings by using the String.compareTo(String) as Integer Function.

It will return an Integer indicating which String is of greater value.

If textbox1.Text.CompareTo(textbox2.Text) = 1 Then textbox2.Text = textbox1.Text

would be the solution to your problem.


Are you expecting integer value in your text boxes? However the principal of

itext1 = convert.ToInt32(Textbox1.text)
itext2 = convert.ToInt32(Textbox2.text)
if (itext1 < itext2) then
  Textbox1.text=Textbox2.text ' See above comment


try this method if you are comparing two string i.e to textbox string : String.Compare Method (String, String, Boolean)


By Using ternary operator ? Do this:

   textbox2.Text= textbox1.Text > textbox2.Text ? textbox1.Text:textbox2.Text
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜