Jump to content

[SOLVED] Number of lines in a EditBox?


Recommended Posts

Hi guys, i have this script:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 248, 180)
$Edit = GUICtrlCreateEdit("", 8, 8, 233, 121)
$Button = GUICtrlCreateButton("Verify", 8, 136, 233, 33)
GUISetState(@SW_SHOW)

GUICtrlSetData($Edit, "Number of lines (0)" & @CRLF & "Test1" & @CRLF & "Test2")

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button
   $FinalList = StringSplit(GUICtrlRead($Edit), @CR)
   For $i = 2 To $FinalList[0]
    MsgBox(64, "Verify", $FinalList[$i])
   Next
EndSwitch
WEnd

I can't find a way for count the number of lines in a EditBox. I have see:

_FileCountLines()

FileReadLine

But i can't apply directy to a EditBox without write them on a file and then EditBox read it.

How to solve this?

Thanks ;)

Edited by johnmcloud
Link to comment
Share on other sites

Doesn't $FinalList[0] give you the number of lines? If not try to use

$FinalList = StringSplit(GUICtrlRead($Edit), @CR, 1)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

FileWrite("C:temptest.txt", $FinalList[1])?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I don't want to write on a file ;)

if I wanted to write to the file I used _FileCountLines()

The goal is:

1) GUICtrlSetData write the data ( Test1 e Test2 )

2) I'll read the value and check the number of line with $FinalList[0]

3) GUICtrlSetData write the number of files ( $FinalList[0] ) and the data ( Test1 e Test2 ) on the EditBox [That's the problem]

All this at startup of the GUI

Edited by johnmcloud
Link to comment
Share on other sites

lol, i have the solution by myself:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 248, 180)
$Edit = GUICtrlCreateEdit("", 8, 8, 233, 121)
$Button = GUICtrlCreateButton("Verify", 8, 136, 233, 33)
GUISetState(@SW_SHOW)

$Test = "Test1" & @CRLF & "Test2" & @CRLF & "Test3" & @CRLF & "Test4"
GUICtrlSetData($Edit, $Test)
$FinalList = StringSplit(GUICtrlRead($Edit), @CR, 1)
GUICtrlSetData($Edit, "Number of lines ( " & $FinalList[0] & ")" & @CRLF & $Test)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button
   $FinalList = StringSplit(GUICtrlRead($Edit), @CR)
   For $i = 2 To $FinalList[0]
    MsgBox(64, "Verify", $FinalList[$i])
   Next
EndSwitch
WEnd

Thanks water for support ;)

Edited by johnmcloud
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

×
×
  • Create New...