7,764
社区成员
发帖
与我相关
我的任务
分享
Private Function TextIsDouble(ByRef X As Double, txtName As TextBox) As Boolean
Dim i As Byte
Dim cur As Currency
'txtName.text是文本框的值
If IsNumeric(txtName.Text) = True Then
i = InStr(1, txtName.Text, ".", vbTextCompare)
If i > 0 Then
X = Val(Left(txtName.Text, i + 2))
TextIsDouble = True
Else
X = Val(txtName.Text)
TextIsDouble = True
End If
Else
TextIsDouble = False
End If
End Function
private function TextIsLong() as boolean
dim cur as currency
'Text1.text是文本框的值
if isnumeric(text1.text)=true then
if instr(1,text1.Text ,".",vbTextCompare )<>0 then
TextIsLong=false
else
if len(text1.text)>11 then
TextIsLong=false
else
cur = val(text1.text)
if cur<-2,147,483,648 or cur > 2,147,483,647 then
TextIsLong=false
else
TextIsLong=True
end if
end if
end if
else
TextIsLong=false
end if
end function
private sub textbox1_lostfocus()
if trim(textbox1.text)<>"" then
if not isnumeric(textbox1.text) then
msgbox "请输入数值型数据!",48,"提示"
textbox1.setfocus
else
textbox1.text=format(textbox1.text,"###0.00")
end if
end if
end sub