VB中的文本框属性不其作用??!!

来源:百度知道 编辑:UC知道 时间:2024/07/01 15:40:42
VB中的文本框属性 dataformat
我在程序中 编辑dataformat属性为 数字 有千分号

可是程序运行后 文本框中 还是可以输入字母,汉字等
而且千分号没显示

请问怎么回事??!!

赏分用光了 暂时没有了 如果要的话 我明后天给 关键是帮忙讲清楚些 偶是菜鸟 谢谢啦
那么怎么让他只能输入 数字 并有 千位分割号??

SORRY SORRY 笔误 现在改正的 应该是 千位分割号 怎么输入

两个事件
Private Sub Text1_Change()
If Len(Text1.Text) > 0 Then
If Right(Text1.Text, 1) <> "‰" Then
Text1.Text = Text1.Text & "‰"
Text1.SelStart = Len(Text1.Text) - 1
End If
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
补充:
是不是这种效果:
123,456,789
Private Sub Text1_Change()
astr = Replace(Text1.Text, ",", "")
a = Val(astr)
If a > 1000 Then
Text1.Text = Format(a, "0,000")
End If
Text1.SelStart = Len(Text1.Text)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub

DataFormat,不是用来规定你说的千分号的
这个属性是用于数据绑定用的