Jump to content

How to store GUICtrlCreateEdit information as variables


Recommended Posts

No code, just question in general. Let's say we have Edit field

 

$textarea = GUICtrlCreateEdit('', 100, 10, 200, 100)

If I type the following into this edit field:

test1
test2

I want for an array to contain test1 and test2 (so I could grab the values later).

Obviously if I type 5 lines of text I want array to contain 5 entries etc etc.

What is the best way to go about this?

Link to comment
Share on other sites

Thanks, and for those who need the code:

 

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>

Opt("GUIOnEventMode", 1)

$main = GUICreate("Basic Template", 400, 300)

$edit       = GUICtrlCreateEdit("", 10, 80, 380, 140)
$button     = GUICtrlCreateButton("Press me!", 320, 260, 70, 25)
GUICtrlSetOnEvent($button, "ButtonFunction")

GUISetOnEvent($GUI_EVENT_CLOSE, "ExitGUI")
GUISetState(@SW_SHOW)

While 1
Sleep(10)
WEnd


Func ButtonFunction()

$data = GUICtrlRead($edit)
$aArray = StringSplit($data, @CRLF, $STR_ENTIRESPLIT)

For $i = 1 To $aArray[0] ; Loop through the array returned by StringSplit to display the individual values.
         MsgBox($MB_SYSTEMMODAL, "", "$aArray[" & $i & "] - " & $aArray[$i])
Next

EndFunc


Func ExitGui ()
Exit ; Exit the program
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...