0

当文本框设置为只读“false”时,我只是不知道如何设置文本长度

the result i get is 98.888888 and i want to set to have only 4 digit to 98.88

i tried to set maxlength in textbox properties but is not working 

and Button1.click
if Length(textbox1.text) > 6 then
enter only six chars
else if Length(textbox1.text) < 6 then
enter up to six chars
also not working

谁能告诉我该怎么做?

4

3 回答 3

0

试试这样:

 TextBox1.Text = "98.8888888"

        If TextBox1.Text.Trim.Length > 5 Then

            TextBox1.Text = TextBox1.Text.Substring(0, 5)

        End If
于 2013-06-08T04:28:12.973 回答
0

有时它会发生..我不知道为什么..

所以,我们必须在 Textbox Textchanged 事件中控制它。

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    TextBox1.Text = mid(TextBox.Text,1,Textbox1.MaxLength)

End Sub
于 2013-06-08T07:57:54.150 回答
0

您可以使用 validate 事件处理程序来格式化文本,然后这样的事情可能会起作用,textbox1.text = textbox1.text.tostring("n2")。

无法使用平板电脑测试它断电

于 2013-06-08T04:37:49.140 回答