找回密码
 加入
搜索
查看: 2976|回复: 6

[AU3基础] 如何将input中数据存入数组中

  [复制链接]
发表于 2011-7-22 20:16:59 | 显示全部楼层 |阅读模式
请问如何将input1,input2,input3....中的数据存入一个数组中,并用msgbox()显示出来。。。我先谢谢大家了。。。
发表于 2011-7-23 03:01:21 | 显示全部楼层


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 261, 121, 192, 124)
$Input1 = GUICtrlCreateInput("", 8, 8, 121, 21)
$Input2 = GUICtrlCreateInput("", 8, 40, 121, 21)
$Input3 = GUICtrlCreateInput("", 8, 72, 121, 21)
$Button1 = GUICtrlCreateButton("保存", 152, 16, 75, 25)
$Button2 = GUICtrlCreateButton("显示", 152, 56, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $aInputs[4]
$aInputs[0] = 3
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $aInputs[1] = GUICtrlRead($Input1)
                        $aInputs[2] = GUICtrlRead($Input2)
                        $aInputs[3] = GUICtrlRead($Input3)
                        MsgBox(0,0,"保存完成")
                Case $Button2
                        For $i = 1 To 3
                                MsgBox(0,0,"Input" & $i & "的内容为:" & $aInputs[$i])
                        Next
                        
        EndSwitch
WEnd
 楼主| 发表于 2011-7-25 13:31:38 | 显示全部楼层
非常感谢。。。
 楼主| 发表于 2011-7-25 14:15:53 | 显示全部楼层
回复 2# sxd
Case $Button1
                        $aInputs[1] = GUICtrlRead($Input1)
                        $aInputs[2] = GUICtrlRead($Input2)
                        $aInputs[3] = GUICtrlRead($Input3)
                        MsgBox(0,0,"保存完成")
如果有100个inputbox,那用循环怎么写上面这段。
发表于 2011-7-25 15:41:17 | 显示全部楼层
回复 4# yanjerry9133
怎么就不肯动点脑子呢?
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 261, 800, 192, 124)
Local $Input[10], $aInputs[10], $str
For $i = 0 To UBound($Input) - 1
        $Input[$i] = GUICtrlCreateInput("", 8, 8 + $i * 32, 121, 21)
Next
$Button1 = GUICtrlCreateButton("保存", 152, 16, 75, 25)
$Button2 = GUICtrlCreateButton("显示", 152, 56, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        For $i = 0 To UBound($Input) - 1
                                $aInputs[1] = GUICtrlRead($Input[$i])
                        Next
                        MsgBox(0, 0, "保存完成")
                Case $Button2
                        $str = ""
                        For $i = 0 To UBound($Input) - 1
                                $str &= "Input" & $i + 1 & "的内容为:" & $aInputs[$i] & @CRLF
                        Next
                        MsgBox(0, 0, $str)
        EndSwitch
WEnd
发表于 2011-7-28 00:01:58 | 显示全部楼层
笔误
$aInputs[$i] = GUICtrlRead($Input[$i])
 楼主| 发表于 2011-8-2 15:01:27 | 显示全部楼层
回复 5# 3mile
我动脑子了,只是想看看能不能这样写input[$i],哈哈,那我就会了。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-14 03:01 , Processed in 0.073966 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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