如何判断 text文本框中的数据类型
求代码最好有注释 谢谢
VBå¯ä½¿ç¨TypeName å½æ°æ¥å¤ææåéçæ°æ®ç±»åã
TypeName å½æ°ï¼è¿åä¸ä¸ª Stringï¼æä¾æå ³åéçä¿¡æ¯ã
TypeName å½æ°ç¤ºä¾
æ¬ç¤ºä¾ä½¿ç¨ TypeName å½æ°è¿åæå ³åéçä¿¡æ¯ã
' 声æåéã
Dim NullVar, MyType, StrVar As String, IntVar As Integer, CurVar As Currency
Dim ArrayVar (1 To 5) As Integer
NullVar = Null ' 设置åéå¼ä¸º Nullã
MyType = TypeName(StrVar) ' è¿å "String"ã
MyType = TypeName(IntVar) ' è¿å "Integer"ã
MyType = TypeName(CurVar) ' è¿å "Currency"ã
MyType = TypeName(NullVar) ' è¿å "Null"ã
MyType = TypeName(ArrayVar) ' è¿å "Integer()"ã
温馨提示:答案为网友推荐,仅供参考
第1个回答 2010-07-18
Private Sub Command1_Click()
Dim s As String
If IsNumeric(Text1.Text) Then '判断text是否是数字格式
s = "数字"
Else
s = "字符串" '否则是字符串
End If
Print s
End Sub本回答被提问者采纳
Dim s As String
If IsNumeric(Text1.Text) Then '判断text是否是数字格式
s = "数字"
Else
s = "字符串" '否则是字符串
End If
Print s
End Sub本回答被提问者采纳