Public Function F_InputNumeric(KeyAscii As Integer) As Integer '*** 目的:通用过程 输入时只能接受的数字和“.” Select Case KeyAscii Case 48 To 57, 8 F_InputNumeric = KeyAscii Case Else F_InputNumeric = 0 End Select End Function 在key Press 中调用 形式如 keyascii=f_inputnumeric(keyascii)
Private Sub Text1_KeyPress(KeyAscii As Integer) Print KeyAscii If KeyAscii < 49 Or KeyAscii > 60 Then If KeyAscii <> 8 And KeyAscii <> 32 And KeyAscii <> 13 Then MsgBox "必须为数字" End If End If End Sub
错了,这样 Private Sub Text1_KeyPress(KeyAscii As Integer) Print KeyAscii If KeyAscii < 48 Or KeyAscii > 60 Then If KeyAscii <> 8 And KeyAscii <> 32 And KeyAscii <> 13 Then MsgBox "必须为数字" End If End If End Sub
http://www.csdn.net/expert/topic/775/775597.xml?temp=.8942987function chkdata(intData as integer,optional strString as string="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")as integer chkdata=iif( instr(strstring,ucase(asc(intdata)))=0 ,0,intdata) end functionPrivate Sub Text1_KeyPress(KeyAscii As Integer) if not KeyAscii=13 then keyascii=chkdata(keyascii) End Sub差不多象上面的吧 如果需要别的字符写在strstring参数中自己看就是了 部需要注释了吧?
private sub text1_keypress(keyascii as interge) if keyascii<0 or keyascii>9 then keyascii=0 end if end sub 类似的 ,记不清楚了
本示例使用 FileCopy 语句来复制文件。示例中假设 SRCFILE 为含有数据的文件。Dim SourceFile, DestinationFile
SourceFile = "SRCFILE" ' 指定源文件名。
DestinationFile = "DESTFILE" ' 指定目的文件名。
FileCopy SourceFile, DestinationFile ' 将源文件的内容复制到目的文件中。FileCopy 语句
复制一个文件。语法FileCopy source, destinationFileCopy 语句的语法含有以下这些命名参数:部分 描述
source 必要参数。字符串表达式,用来表示要被复制的文件名。source 可以包含目录或文件夹、以及驱动器。
destination 必要参数。字符串表达式,用来指定要复制的目地文件名。destination 可以包含目录或文件夹、以及驱动器。
说明如果想要对一个已打开的文件使用 FileCopy 语句,则会产生错误。
'*** 目的:通用过程 输入时只能接受的数字和“.”
Select Case KeyAscii
Case 48 To 57, 8
F_InputNumeric = KeyAscii
Case Else
F_InputNumeric = 0
End Select
End Function
在key Press 中调用 形式如 keyascii=f_inputnumeric(keyascii)
Print KeyAscii
If KeyAscii < 49 Or KeyAscii > 60 Then
If KeyAscii <> 8 And KeyAscii <> 32 And KeyAscii <> 13 Then
MsgBox "必须为数字"
End If
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Print KeyAscii
If KeyAscii < 48 Or KeyAscii > 60 Then
If KeyAscii <> 8 And KeyAscii <> 32 And KeyAscii <> 13 Then
MsgBox "必须为数字"
End If
End If
End Sub
chkdata=iif( instr(strstring,ucase(asc(intdata)))=0 ,0,intdata)
end functionPrivate Sub Text1_KeyPress(KeyAscii As Integer)
if not KeyAscii=13 then keyascii=chkdata(keyascii)
End Sub差不多象上面的吧
如果需要别的字符写在strstring参数中自己看就是了
部需要注释了吧?
if keyascii<0 or keyascii>9 then
keyascii=0
end if
end sub
类似的 ,记不清楚了