我只是不知道当文本框设置为只读“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
谁能告诉我怎么做?
答案 0 :(得分:0)
尝试这样:
TextBox1.Text = "98.8888888"
If TextBox1.Text.Trim.Length > 5 Then
TextBox1.Text = TextBox1.Text.Substring(0, 5)
End If
答案 1 :(得分:0)
你可以使用validate事件处理程序来格式化文本,然后像这样的东西可以工作,textbox1.text = textbox1.text.tostring(“n2”)。
无法使用平板电脑测试它的电源
答案 2 :(得分: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