我只想在autoit运行一个循环,如果我接受任何类型的数字,那么代码将不会执行代码在下面,
If $Number($read, "")Then
;We have it, display the message.
MsgBox($MB_SYSTEMMODAL, "", "The following values were converted to a numeric value:" & @CRLF & _
$Number)
Else
;Get Existing Data of edit
$read2 = GUICtrlRead($hEdit)
$text = $read2 & @CRLF & $read ;
答案 0 :(得分:0)
我不是百分百肯定我明白你需要什么,但我有个主意。
如果我理解正确,你想检查一个值是否为数字,如果不是则执行代码。我对么?如果是这样,我相信,最好的方法是使用IsNumber()函数。例如:
$testVar = 1
If NOT (IsNumber($testVar)) Then
MsgBox(0,"Title","This code will not execute as the variable's a number.")
Else
MsgBox(0,"Title","This code WILL execute since the variable is a number.")
EndIf
$testVar2 = "String"
If NOT (IsNumber($testVar2)) Then
MsgBox(0,"Title","This code WILL execute since the variable is NOT a number.")
Else
MsgBox(0,"Title","This code will not execute as the variable's NOT a number.")
EndIf
如果我没有正确理解,那就忽略我刚才所说的一切。
请记住,如果$ testVar是一个数字,但该数字是引号,则会将其识别为字符串,并执行,因为它不是数字。
我希望这有帮助!,
添