hkzhangt 发表于 2010-8-22 23:39:37

求助一个循环,怎么写才能达到这样的效果?

本帖最后由 hkzhangt 于 2010-8-23 23:01 编辑

小弟想写一个循环实现这样的功能出现一个窗口以后点击确定可以退出,点击取消后提示错误对话框,并且并且返回到初始窗口,直到点击确定才能退出
哪位大哥可以帮我一下?



四楼是正解
While 1

      $Flag = MsgBox(1, "", "")

      If $Flag = 1 Then

                Exit

      ElseIf $Flag = 2 Then

                MsgBox(16, "", "")

      EndIf

WEnd

landays 发表于 2010-8-23 01:45:54

While 1
        Sleep(10)
        InputBox("Question", "Where were you born?", "Planet Earth", "", -1, -1)
        If @error Then
                MsgBox(0, "", "错误")
        Else
                Exit
        EndIf
WEnd建议多看看帮助

netegg 发表于 2010-8-23 02:33:30

本帖最后由 netegg 于 2010-8-23 02:49 编辑

什么乱七八糟的?不好好看看帮助,这么简单的问题也要问。这个根本就不是循环的事
$msg= msgbox(1,'','')
If $msg=1 Then
        Exit
Else
      msgbox('','','error')
EndIf

lixiaolong 发表于 2010-8-23 11:44:25

循环用 while就行了,

这是利用MsgBox

返回值:
OK(确定)1
CANCEL(取消)2While 1
        $Flag = MsgBox(1, "", "")
        If $Flag = 1 Then
                Exit
        ElseIf $Flag = 2 Then
                MsgBox(16, "", "")
        EndIf
WEnd这是自己建立窗口#NoTrayIcon
#include <GUIConstants.au3>

$Form1 = GUICreate("", 200, 100 - 1, -1)
$Button1 = GUICtrlCreateButton("確定", 40, 20, 120, 25, 0)
$Button2 = GUICtrlCreateButton("取消", 40, 50, 120, 25, 0)
GUISetState(@SW_SHOW)

While 1

        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        MsgBox(16, "", "")
                        ContinueLoop
                Case $Button1
                        Exit
                Case $Button2
                        MsgBox(16, "", "")
        EndSwitch

WEnd

zzz867 发表于 2010-8-23 14:56:40

其实看点教材这个很简单的,估计楼主没好好看哦
页: [1]
查看完整版本: 求助一个循环,怎么写才能达到这样的效果?