在 If Else 条件下,如果取了任何数字,它将显示 error.how 它将在 AUTOIT 中完成
In If Else condition if any number taken then it will show error.how it will be done in AUTOIT
我只想 运行 在 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 ;
如果我没理解错的话,你想检查一个值是否为数字,如果不是则执行代码。如果是这样,请使用 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
是一个数字,但该数字在引号中,它将被识别为字符串并执行(因为它不是数字)。
我只想 运行 在 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 ;
如果我没理解错的话,你想检查一个值是否为数字,如果不是则执行代码。如果是这样,请使用 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
是一个数字,但该数字在引号中,它将被识别为字符串并执行(因为它不是数字)。