找回密码
 加入
搜索
查看: 3925|回复: 9

[GUI管理] [已解决]計算Edit1 Edit2 Edit3..內的數字 該如何做ㄚ?

  [复制链接]
发表于 2010-9-4 14:10:24 | 显示全部楼层 |阅读模式
本帖最后由 tcpuuu 于 2010-9-6 14:19 编辑

GUICreate(" Win ", 110, 302, 800, 2)

$L1 = GUICtrlCreateLabel("1", 2, 2, 62, 36, 0x00800000) ;$WS_BORDER = 0x00800000
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetFont(-1, 24)

$L2 = GUICtrlCreateLabel("2", 2, 40, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$L3 = GUICtrlCreateLabel("3", 2, 78, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$L4 = GUICtrlCreateLabel("4", 2, 116, 62, 36, 0x00800000) ;$WS_BORDER = 0x00800000
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$L5 = GUICtrlCreateLabel("5", 2, 154, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)

$L6 = GUICtrlCreateLabel("6", 2, 192, 62, 36, 0x00800000)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 24)
$1Button = GUICtrlCreateButton("往下進1格", 1, 232, 60, 30)
$2Button = GUICtrlCreateButton("停在原地", 1, 266, 60, 30)
;--------------------------------------
GUICtrlCreateInput ( "", 68,  8, 30, 20)
GUICtrlCreateInput ( "", 68, 46, 30, 20)
GUICtrlCreateInput ( "", 68, 84, 30, 20)
GUICtrlCreateInput ( "", 68,122, 30, 20)
GUICtrlCreateInput ( "", 68,160, 30, 20)
GUICtrlCreateInput ( "", 68,198, 30, 20)
$3Button = GUICtrlCreateButton("計算", 68, 220, 30, 20)
GUICtrlCreateInput ( "", 68,242, 30, 20)
$4Button = GUICtrlCreateButton("執行", 63, 266, 40, 30)

GUISetState()
Dim $bj = $L1
Dim $exe[6] = ["1.exe", "2.exe", "3.exe", "4.exe", "5.exe", "6.exe"]

While 1

        $msg = GUIGetMsg()

        Switch $msg

                Case -3

                        Exit

                Case $1Button

                        Go($msg)
                Case $2Button
                         MsgBox(0, 0, $exe[$bj - 3], 1)
                        ;RUN($exe[$bj - 3])

        EndSwitch

WEnd

Func Go($msg)

        If ($msg = $1Button And $bj = $L6)  Then Return

        GUICtrlSetBkColor($bj, 0xFFFFFF)

        $bj += 1     
        
        GUICtrlSetBkColor($bj, 0xFF0000)
        MsgBox(0, 0, $exe[$bj - 3], 1)
        ;RUN($exe[$bj - 3])

EndFunc   ;==>Go

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

 楼主| 发表于 2010-9-4 20:07:36 | 显示全部楼层
afan超級版主 你在那兒ㄚ?  快來幫忙一下
发表于 2010-9-4 20:15:19 | 显示全部楼层
我是看不懂你的意思...
 楼主| 发表于 2010-9-4 20:28:07 | 显示全部楼层
afan超級版主 你好!
手動 輸入數字, 然後可以按下3Button  做計算
計算的結果 自動填入Edit7 內

按4Button 可以 條件式執行程式
-------------------------------------------
如果 Edit7內的數字 大於0  然後
MsgBox(0, 0,計算的結果大於0, 1)
Else
MsgBox(0, 0,計算的結果小於或等於0, 1)
EndIf
发表于 2010-9-4 21:56:56 | 显示全部楼层
本帖最后由 afan 于 2010-9-4 21:59 编辑

剔除了无关的代码, 问题应该精简;另外,贴代码最好用代码的标签,方便浏览和使用。
GUICreate(" Win ", 110, 302, 800, 2)
;................
;--------------------------------------
Dim $Input[8] = [7], $Val
$Input[1] = GUICtrlCreateInput("", 68, 8, 30, 20)
$Input[2] = GUICtrlCreateInput("", 68, 46, 30, 20)
$Input[3] = GUICtrlCreateInput("", 68, 84, 30, 20)
$Input[4] = GUICtrlCreateInput("", 68, 122, 30, 20)
$Input[5] = GUICtrlCreateInput("", 68, 160, 30, 20)
$Input[6] = GUICtrlCreateInput("", 68, 198, 30, 20)
;$3Button = GUICtrlCreateButton("計算", 68, 220, 30, 20)
$Input[7] = GUICtrlCreateInput("", 68, 242, 30, 20)
$4Button = GUICtrlCreateButton("執行", 63, 266, 40, 30)

GUISetState()
;..........

While 1
        $msg = GUIGetMsg()
        Switch $msg
                Case -3
                        Exit
                Case $4Button
                        $Val = 0
                        _c()

        EndSwitch

WEnd

Func _c()
        For $i = 1 To 6
                $Val += Number(GUICtrlRead($Input[$i]))
        Next
        GUICtrlSetData($Input[7], $Val)
        If $Val > 0 Then Return MsgBox(64, 0, '計算的結果大於0', 1)
        MsgBox(48, 0, '計算的結果小於或等於0', 1)
EndFunc   ;==>_c

评分

参与人数 1金钱 +20 收起 理由
水木子 + 20

查看全部评分

 楼主| 发表于 2010-9-4 22:26:36 | 显示全部楼层
感謝afan超級版主:
您真是很厲害的高手.......
我正在 將 兩邊合在一起, 這樣我開1個就好
我都只用 記事本 編代码, 不好意思  添加了您的不便

我會找 編輯器來用的
再次感謝!
发表于 2010-9-4 22:33:05 | 显示全部楼层
回复 6# tcpuuu


    不是我厉害,是问题如果说清楚了就很简单~ _ _||

p.s 我指的是在发帖时在全部代码的前后加上代码标签(看看发帖的高级模式),这样就会使帖子有代码的效果,和使用什么编辑代码无关的~
发表于 2010-9-5 14:24:10 | 显示全部楼层
本帖最后由 landays 于 2010-9-5 14:29 编辑

Msgbox (0,0,"请教一下版主,怎么使代码高亮?")

噢,搞懂了
发表于 2010-9-11 10:45:35 | 显示全部楼层
本帖最后由 zps26 于 2010-9-12 00:20 编辑

来AU3好几个月了,今日才注意afan版主发的代码可以超链接查询函数,继续学习,可就是弄不出来“高亮切换”;根据afan版主所说,重新试验成功,谢谢afan!
 Msgbox ( 0, 0, "请教一下版主,怎么使代码高亮?")
发表于 2010-9-11 17:27:05 | 显示全部楼层
回复 9# zps26


    代码外面加[au3]和[ /au3]就行了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-1 10:18 , Processed in 0.080098 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表