用text輸入一個數值
如何能夠判斷他是否為一個整數
2006-04-02 09:19:30 · 4 個解答 · 發問者 凱翔 3 in 電腦與網際網路 ➔ 程式設計
Private Sub Command1_Click()If IsNumeric(Text1) Then If Text1 = Int(Text1) Then MsgBox "是整數"End IfEnd Sub
2006-04-02 10:23:26 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
If InStr(Text1, ".") = 0 And IsNumeric(CInt(Text1)) Then
※Text1若內含文字時,發生錯誤請另外處理
2006-04-02 10:47:49 · answer #2 · answered by ? 5 · 0⤊ 0⤋
Msgbox IsNumeric(text1.text)
如果是數字就會傳回 True
2006-04-02 19:27:18 補充:
If IsNumeric(Text1.Text) Then
If InStr(1, Text1.Text, ".") = 0 Then
MsgBox "整數"
Else
MsgBox "小數"
End If
Else
MsgBox "非數字"
End If
2006-04-02 09:54:27 · answer #3 · answered by 玉潔 1 · 0⤊ 0⤋
是有沒有認真在上程式課阿你們?!
不要在這邊降低網友素質!!!!!!!!
還偷在知識+問功課???!!!!
扣點扣點啦!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2010-02-26 11:40:31 · answer #4 · answered by 水面森 1 · 0⤊ 2⤋