本帖最后由 xlcwxl 于 2010-11-20 08:02 编辑
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 178, 99, 192, 124)
$Input1 = GUICtrlCreateInput("", 32, 32, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 80, 56, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
If _isIP(GUICtrlRead($Input1)) Then
MsgBox(0, "", "是合法IP地址")
Else
MsgBox(0, "", "不是合法IP地址")
EndIf
EndSwitch
WEnd
Func _isIP($ip)
Return StringRegExp($ip, "^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$")
EndFunc ;==>_isIP
|