请高手帮忙编辑完善一下脚本
1.请问下面的脚本在点“确定”时如何使用 IF...Then 判断Inputbox输入框中输入的是数字则计算结果,如果输入英文字母或中文等非数字数值则提示输入错误,请高手帮忙编辑一下2.有人提出使用IsNumber ,不过本人比较菜,试了几次不成功,请高手帮忙编辑完善一下
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
_Singleton("test")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 480, 177, 192, 124)
$Input1 = GUICtrlCreateInput("", 16, 32, 81, 30)
$Label1 = GUICtrlCreateLabel("+", 112, 32, 10, 17)
$Input2 = GUICtrlCreateInput("", 136, 32, 81, 30)
$Input3 = GUICtrlCreateInput("", 248, 32, 89, 30)
$Button1 = GUICtrlCreateButton("确定", 368, 16, 81, 25, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("=", 224, 40, 10, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case$Button1
$insss=GUICtrlRead($Input1)
$edsss=GUICtrlRead($Input2)
GUICtrlSetData($Input3,$insss+$edsss)
EndSwitch
WEnd
[ 本帖最后由 17911 于 2009-4-15 20:11 编辑 ] #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
_Singleton("test")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 480, 177, 192, 124)
$Input1 = GUICtrlCreateInput("", 16, 32, 81, 30)
$Label1 = GUICtrlCreateLabel("+", 112, 32, 10, 17)
$Input2 = GUICtrlCreateInput("", 136, 32, 81, 30)
$Input3 = GUICtrlCreateInput("", 248, 32, 89, 30)
GUICtrlSetState(-1,$gui_disable)
$Button1 = GUICtrlCreateButton("确定", 368, 16, 81, 25, $WS_GROUP)
$Label3 = GUICtrlCreateLabel("=", 224, 40, 10, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case$Button1
$insss=GUICtrlRead($Input1)
$edsss=GUICtrlRead($Input2)
GUICtrlSetData($Input3,$insss+$edsss)
EndSwitch
mycheck($Input1)
mycheck($Input2)
WEnd
Func mycheck($ctrl)
$a=GUICtrlRead($ctrl)
if StringRegExp($a,"[^\d]",0 ) Then
$a=StringRegExpReplace($a,"[^\d]","")
GUICtrlSetData($ctrl,$a)
SoundPlay(@WindowsDir&'\media\Windows XP 叮当声.wav')
EndIf
EndFunc
页:
[1]