[已解决]请教关于 使用两个 Form 时的问题
本帖最后由 hnfeng 于 2014-10-24 15:12 编辑没有玩过两个 Form,可能是格式不对?语法不对?总之是有大问题,无从下手了,只好求助。
当点击了 $Form1 中的【批量网址】后,想得到一批有规律的网址,目前的问题是:
1、在 $Form2 中,点击 取消、右上角X 时,会直接退出程序。如果编译成exe运行,有Error:Variable used without being declared提示,然后退出。
(我希望的是 退回到 $Form1 界面)
2、当 “结束数值”小于“开始数值”时, 会直接退出程序。如果编译成exe运行,有Error:Variable subscript badly formatted提示,然后退出。
(我希望有 Msgbox 提示,然后仍然在 $Form2 中)
看不懂Error信息,不知道哪里的问题,请高手帮忙看看,谢谢。#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Array.au3>
$Form1 = GUICreate("xxxxx", 874, 456)
Global $gu_Button
$gu_Button = GUICtrlCreateButton("开始", 392, 208, 89, 25)
$gu_Button = GUICtrlCreateButton("退出", 392, 248, 89, 25)
$gu_Button = GUICtrlCreateButton("批量网址", 392, 288, 89, 25)
GUISetState(@SW_SHOW, $Form1)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $gu_Button
_GOGOGO()
Case $gu_Button
Exit
Case $gu_Button
_BatchUrl()
EndSwitch
WEnd
Func _GOGOGO()
MsgBox(0, "", "按了【开始】")
EndFunc
Func _BatchUrl()
GUISetState(@SW_HIDE, $Form1)
$Form2 = GUICreate("Form2", 615, 260, -1, -1, -1, -1, $Form1)
$Group21 = GUICtrlCreateGroup("URL", 8, 8, 601, 73)
$Label21 = GUICtrlCreateLabel("A-固定不变", 232, 60, 62, 17)
$Label22 = GUICtrlCreateLabel("B-变动", 480, 60, 38, 17)
$Label23 = GUICtrlCreateLabel("C-固定不变", 536, 60, 62, 17)
$Input21 = GUICtrlCreateInput("http://www.abcdefg.com/abcd/keys-", 16, 32, 441, 21)
$Input22 = GUICtrlCreateInput("####", 464, 32, 65, 21, $ES_CENTER + $ES_READONLY)
$Input23 = GUICtrlCreateInput(".html", 536, 32, 65, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group22 = GUICtrlCreateGroup("B-变动", 8, 88, 601, 49)
$Input24 = GUICtrlCreateInput("1", 216, 104, 105, 21, $ES_NUMBER)
$Label24 = GUICtrlCreateLabel("起始数值:", 160, 108, 55, 17)
$Input25 = GUICtrlCreateInput("50", 464, 104, 105, 21, $ES_NUMBER)
$Label25 = GUICtrlCreateLabel("结束数值:", 408, 108, 55, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Edit21 = GUICtrlCreateEdit("", 8, 152, 601, 70)
$Button21 = GUICtrlCreateButton("确定", 171, 226, 105, 25)
$Button22 = GUICtrlCreateButton("取消", 339, 226, 105, 25)
GUISetState(@SW_SHOW, $Form2)
While 1
$nMsg = GUIGetMsg()
GUICtrlSetData($Edit21, GUICtrlRead($Input21) & GUICtrlRead($Input24) & GUICtrlRead($Input23) & @CRLF & "......" & _
@CRLF & GUICtrlRead($Input21) & GUICtrlRead($Input25) & GUICtrlRead($Input23))
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
ExitLoop
Case $Button21
If GUICtrlRead($Input24) < GUICtrlRead($Input25) Then
Local $n = GUICtrlRead($Input25) - GUICtrlRead($Input24)
Local $batArray[$n + 1]
For $i = 0 To $n
$batArray[$i] = "Url_" & $i + 1
$batArray[$i] = GUICtrlRead($Input21) & GUICtrlRead($Input24) + $i & GUICtrlRead($Input23)
Next
ExitLoop
Else
MsgBox(0, "", "“结束数值”必须大于“开始数值”")
EndIf
Case $Button22
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
ExitLoop
EndSwitch
WEnd
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $Form1)
$sUrl_b = $batArray
_ArrayDisplay($sUrl_b)
EndFunc
Local $batArray 两个窗口不是这么搞的,你看看帮助中的“GUI界面相关”-“GUI 相关 - 消息循环模式“的有关内容吧! 回复 4# shqf
谢谢,已经搞掂了 学习了,2个窗口还真是基础
页:
[1]