我自己这样检查感觉很不到位;希望各位给点好些的方法;能够检查全面一些
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Group1 = GUICtrlCreateGroup("SelectDirectory", 16, 96, 577, 89)
$Input1 = GUICtrlCreateInput("", 24, 136, 481, 21)
$Button1 = GUICtrlCreateButton("...", 512, 136, 75, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("确定", 520, 208, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUICtrlSetData($Input1,FileSelectFolder("",""))
Case $Button2
Local $path = GUICtrlRead($Input1)
If $path = "" Then
MsgBox(0,"提示","目录不能为空。")
ElseIf StringMid($path,2,2) <> ":\" Then
MsgBox(0,"提示","路径错误。")
Else
MsgBox(0,"","路径是正确的")
EndIf
EndSwitch
WEnd
这样当第一个字符不为英文字母也是正确;因为我只检查了第二和第三个是否等于 :\ ,各位还有什么更好的方法吗?谢谢 |