找回密码
 加入
搜索
查看: 2495|回复: 7

[系统综合] [已解决]GUICtrlRead如何返回(输入框内的)纯数值?(有源码)

  [复制链接]
发表于 2012-8-7 19:08:11 | 显示全部楼层 |阅读模式
本帖最后由 邪恶海盗 于 2012-8-7 22:06 编辑

#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#NoTrayIcon;右下角不显示图标

$WinMain = GUICreate("Form", 670, 220) ;创建主窗口

$Input1 = GUICtrlCreateInput("", 102, 59, 55, 22, $ES_CENTER)
$Input2 = GUICtrlCreateInput("", 102, 100, 55, 22, $ES_CENTER)

$Button1 = GUICtrlCreateButton("开始计算", 290, 180, 90, 30, $ES_CENTER) ;横坐标,纵坐标,长,宽
$mw = GUICtrlRead($Input1)
$mc = GUICtrlRead($Input2)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        ;DirRemove($Temp, 1)
                        Exit
Case $Button1
                        MsgBox(0 + 262144, "", $mw, 3)
        EndSwitch
WEnd


大家帮我瞧瞧,如果最后用GUICtrlRead($input1)可以正常显示,用$mw就无法显示了...
发表于 2012-8-7 19:44:11 | 显示全部楼层
点一次Button1 就要 用 GUICtrlRead读$Input1 放到 $mv
 楼主| 发表于 2012-8-7 20:25:28 | 显示全部楼层
回复 2# veket_linux


   意思是只能用GUICtrlRead($Input1),而不能先定义$mw,再调用$mw?
发表于 2012-8-7 21:29:54 | 显示全部楼层
把 $mv = ... 放到Case $Button1里面
 楼主| 发表于 2012-8-7 21:47:35 | 显示全部楼层
本帖最后由 邪恶海盗 于 2012-8-7 21:49 编辑
把 $mv = ... 放到Case $Button1里面
yhxhappy 发表于 2012-8-7 21:29



    可以了,谢谢!

还有一个问题,如何将$mw的值保留为整数???
发表于 2012-8-7 21:53:40 | 显示全部楼层
回复 3# 邪恶海盗
因为程序运行到循环的时候,input里面还是没有输入,除非你在循环之前就输入值就没有问题了。
#include <Date.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#NoTrayIcon;右下角不显示图标

$WinMain = GUICreate("Form", 670, 220) ;创建主窗口

$Input1 = GUICtrlCreateInput("123", 102, 59, 55, 22, $ES_CENTER)
$Input2 = GUICtrlCreateInput("", 102, 100, 55, 22, $ES_CENTER)

$Button1 = GUICtrlCreateButton("开始计算", 290, 180, 90, 30, $ES_CENTER) ;横坐标,纵坐标,长,宽
$mw = GUICtrlRead($Input1)
$mc = GUICtrlRead($Input2)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        ;DirRemove($Temp, 1)
                        Exit
                Case $Button1
                        MsgBox(0 + 262144, "", $mw, 3)
        EndSwitch
WEnd
发表于 2012-8-7 21:57:06 | 显示全部楼层
回复 5# 邪恶海盗

用int()函数取整,当然你可以限制输入框只能输入数字先
 楼主| 发表于 2012-8-7 22:06:02 | 显示全部楼层
回复 7# xms77


    输入框里的数字是需要根据实际情况变动的...


用Round()搞定了...
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-30 03:22 , Processed in 0.110096 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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