判断INPUT的输入状态【已解决】
本帖最后由 woeiwoei 于 2010-9-6 10:35 编辑#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TEST", 394, 132, 192, 114)
$Input=GUICtrlCreateInput("", 112, 32, 121, 21)
$Input2=GUICtrlCreateInput("", 112, 80, 121, 21,0x0020)
$Button1 = GUICtrlCreateButton("保存", 256, 32, 75, 25)
$Button2 = GUICtrlCreateButton("重置", 256, 80, 75, 25)
$Label1 = GUICtrlCreateLabel("账号:", 80, 39, 30, 17)
$Label2 = GUICtrlCreateLabel("密码:", 80, 86, 30, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
BAOCUN()
panduan()
pand()
quanbu()
Case $Button2
chongzhi()
EndSwitch
WEnd
Func BAOCUN()
$PUT1=GUICtrlRead($Input)
$PUT2=GUICtrlRead($Input2)
If $PUT1 ='' And $PUT2="" Then
MsgBox(64,"提示","请填写账号和密码")
Return
EndIf
EndFunc
Func panduan()
$PUT1=GUICtrlRead($Input)
$PUT2=GUICtrlRead($Input2)
If $PUT2<>"" And $PUT1="" Then
MsgBox(64,"提示","请填写账号")
Return
EndIf
EndFunc
Func pand()
$PUT1=GUICtrlRead($Input)
$PUT2=GUICtrlRead($Input2)
If $PUT1<>"" And $PUT2="" Then
MsgBox(64,"提示","请填写密码")
Return
EndIf
EndFunc
Func quanbu()
$PUT1=GUICtrlRead($Input)
$PUT2=GUICtrlRead($Input2)
If $PUT1 <>'' And $PUT2<>"" Then
MsgBox(64,"提示","您的 账号为:"&$PUT1&" 密码为:"&$PUT2&" 如要修改请点重置!")
GUICtrlSetState($Input,$GUI_DISABLE)
GUICtrlSetState($Input2,$GUI_DISABLE)
EndIf
EndFunc
Func chongzhi()
GUICtrlSetState($Input,$GUI_ENABLE)
GUICtrlSetState($Input2,$GUI_ENABLE)
GUICtrlSetData($Input,"")
GUICtrlSetData($Input2,"")
MsgBox(64,"提示","数据已重置!")
EndFunc试验了半天也只能用这个方法了。那位大大能给优化下吗?还有其他方法去判断? 应该用不了这么多函数。简单改了一下,你试试:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("TEST", 394, 132, 192, 114)
$Input = GUICtrlCreateInput("", 112, 32, 121, 21)
$Input2 = GUICtrlCreateInput("", 112, 80, 121, 21, 0x0020)
$Button1 = GUICtrlCreateButton("保存", 256, 32, 75, 25)
$Button2 = GUICtrlCreateButton("重置", 256, 80, 75, 25)
$Label1 = GUICtrlCreateLabel("账号:", 80, 39, 30, 17)
$Label2 = GUICtrlCreateLabel("密码:", 80, 86, 30, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
BAOCUN()
;panduan()
;pand()
;quanbu()
Case $Button2
chongzhi()
EndSwitch
WEnd
Func BAOCUN()
$PUT1 = GUICtrlRead($Input)
$PUT2 = GUICtrlRead($Input2)
If $PUT1 <> '' And $PUT2 <> "" Then
MsgBox(64, "提示", "您的 账号为:" & $PUT1 & " 密码为:" & $PUT2 & " 如要修改请点重置!")
GUICtrlSetState($Input, $GUI_DISABLE)
GUICtrlSetState($Input2, $GUI_DISABLE)
Else
If $PUT1 = '' And $PUT2 = "" Then
MsgBox(64, "提示", "请填写账号和密码")
ElseIf $PUT1 <> '' Then
MsgBox(64, "提示", "请填写密码")
ElseIf $PUT2 <> '' Then
MsgBox(64, "提示", "请填写账号")
EndIf
EndIf
EndFunc ;==>BAOCUN
Func chongzhi()
GUICtrlSetState($Input, $GUI_ENABLE)
GUICtrlSetState($Input2, $GUI_ENABLE)
GUICtrlSetData($Input, "")
GUICtrlSetData($Input2, "")
MsgBox(64, "提示", "数据已重置!")
EndFunc ;==>chongzhi 回复 2# 3mile
哈哈哈学习了。。怪我基础不好。。。非常感谢你。。。{:face (270):} 测试代码中 学习,,谢谢
页:
[1]