請問如何控制只能在 inputbox 輸入數字,<br>也就是除了數字,其他的字元皆不能接受.<br>謝謝!<br>
:::只能在使用者輸入完之後再做判斷!!!
小琳: 我就是不知要如何寫判斷式,請給個實例吧. 謝謝!
'第一種: if IsNumeric(InputBox(.........)) <> true then msgbox "不是數值" '第二種 sub... if Number_Check(InputBox(........))<>true then msgbox "不是數值" end sub function Number_Check(source as string) as boolean dim I as integer if source <>"" then for i= 1 to len(source) if asc(mid$(source,i,1)))<48 or _ asc(mid$(source,i,1)))>57 then Number_Check = false : exit for end if next i Number_Check = true end if end function 你要哪一個??
路過的路人甲: 謝謝你, 我成功了!
阿戊的VB實驗網(http://vbtester.24cc.com/),VBFAQ=>第79個-如何限定InputBox只能輸入整數數字 採用的做法就和這篇http://www.vbqa.com/discuss/vb.old/read.asp?id=30406我提到的第二種方法一樣(用Timer利用FindWindow抓InputBox的edit的hwnd...)