Switch相关问题
本帖最后由 xlcwxl 于 2010-1-26 00:34 编辑#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 183, 92, -1,-1)
$Combo1 = GUICtrlCreateCombo("", 16, 8, 145, 25)
GUICtrlSetData(-1,'1|2|3',1)
$Button1 = GUICtrlCreateButton("Button1", 88, 40, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
Switch GUICtrlRead($Combo1)
Case "1"
$xz = '1.bat'
Case "2"
$xz = '2.bat'
Case "3"
$xz = '3.bat'
EndSwitch
Case $Button1
MsgBox(64,'',$xz)
EndSwitch
WEnd
为何必须选择一次才能读取数据,默认数据的话一闪而过,为什么?
答案4# 本帖最后由 catcher 于 2010-1-26 00:09 编辑
先给变量设置一个初值
Dim $xz= "1.bat"
$Form1 = GUICreate("Form1", 183, 92, -1,-1)
................
等高手来解答 不明白楼主说什么。,
不明白楼主为什么要搞复杂化?另外如楼上所说赋值,也可方法2,也可其他,多的是
$Form1 = GUICreate("Form1", 183, 92, -1,-1)
$Combo1 = GUICtrlCreateCombo("", 16, 8, 145, 25)
GUICtrlSetData(-1,'1|2|3',1)
$Button1 = GUICtrlCreateButton("Button1", 88, 40, 75, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
MsgBox(64,'',GUICtrlRead($Combo1)&'.bat')
EndSwitch
WEnd2#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 183, 92, -1,-1)
$Combo1 = GUICtrlCreateCombo("", 16, 8, 145, 25)
GUICtrlSetData(-1,'1|2|3',1)
GUICtrlSetState(-1,$GUI_FOCUS)
$Button1 = GUICtrlCreateButton("Button1", 88, 40, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Send('{down}')
Send('{up}')
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
Switch GUICtrlRead($Combo1)
Case "1"
$xz = '1.bat'
Case "2"
$xz = '2.bat'
Case "3"
$xz = '3.bat'
EndSwitch
Case $Button1
MsgBox(64,'',$xz)
EndSwitch
WEnd 回复 4# kn007
谢谢啦
这两种办法我知道,我是想问有更好的办法没 变量 $xz 需要先声明
页:
[1]