woootoo 发表于 2013-4-1 15:40:10

为什闪退啊???问题在哪里??

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=i:\学习资料\图形设计\3\form2.kxf
$Form1_1 = GUICreate("", 531, 442, 192, 124)
$Group1 = GUICtrlCreateGroup("信息输入", 24, 32, 481, 169)
$Input1 = GUICtrlCreateInput("", 176, 64, 73, 21)
$List1 = GUICtrlCreateList("", 350, 39, 121, 162)
$Button1 = GUICtrlCreateButton("添加", 80, 160, 65, 25)
$Button2 = GUICtrlCreateButton("重置", 184, 160, 65, 25)
$Input2 = GUICtrlCreateInput("", 80, 104, 169, 21)
$Label1 = GUICtrlCreateLabel("数量", 80, 64, 28, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("结果显示", 24, 224, 481, 145)
$Label2 = GUICtrlCreateLabel("", 26, 239, 477, 128, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetFont(-1, 36, 800, 0, "宋体")
GUICtrlSetCursor (-1, 2)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("关于", 24, 384, 80, 33)
$Button4 = GUICtrlCreateButton("执行", 304, 384, 80, 33)
$Button5 = GUICtrlCreateButton("退出", 424, 384, 80, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

_main()
Exit

Func _main()
       
While 1
        Local $nMsg
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Input1
                        Local $n=GUICtrlRead($Input1)
                        Local $sz[$n]
                Case$Button1
                       
                        Local $i=GUICtrlRead($Input2)               
                        GUICtrlSetData($List1,$i)
                        For$n=0 To $n=GUICtrlRead($Input1)
                        $sz[$i]=$i
                        Next
                Case $Button2
                        GUICtrlSetData($Input1,"")
                        GUICtrlSetData($Input2,"")
                        GUICtrlSetData($List1,"")
                Case $Button4
                        _zhixing($sz)
                       
          Case $Button5
                  Exit
               
        EndSwitch
WEnd
EndFunc

Func _zhixing($sz)
        Local $Max = UBound($sz,1)
        Local $i
        For $i = 1 To 30
                Local $sj= Random(1, $Max,1)
                Local $jg= $sz[$sj]
                Sleep(100)
                GUICtrlSetData($Label2, $jg)
        Next
EndFunc

zch11230 发表于 2013-4-1 20:51:44

声明变量不够严谨
页: [1]
查看完整版本: 为什闪退啊???问题在哪里??