Sign in to follow this  
Followers 0
kneze

Text File to Listbox without Columns

2 posts in this topic

Hi

i have a text File (samples.txt) with following Content;

bblablabala: hdkh

hfaksfa: tt445

asdfga: gergeg

gfqwgfq: ewfqerf

I try to get content of Samples.txt and put it to a listbox. The only what i done is to put content to a messagebox.

What i need to get TXT File content without Column or header to Listbox ?

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListview.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#Include <Array.au3>
#include<EditConstants.au3>
#include<GUIConstants.au3>
#Include <GuiListBox.au3>



Dim $array, $i, $file, $CountLines, $List1, $text
Global $aArray[1000]    

$Form1 = GUICreate("Form1", 718, 733, 230, 124)
$List1 = GUICtrlCreateListView("", 165, 90, 250, 331)

$Button1 = GUICtrlCreateButton("start", 420, 395, 116, 31)


GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $Button1
            
    $Countfile= _FileCountLines("C:\Temp\samples.txt")

    $file = "C:\Temp\samples.txt"
    
For $i = 1 To $CountFile
    $var1= FileReadLine($file, $i)
$text = $text & @CRLF & $var1 
;_GUICtrlListBox_AddString($List1, $text)
Next

MsgBox(0,"test",$Text)
exit

            

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



I found a way. I use $list1 = GUICtrlCreateList("", 165, 90, 250, 331)

Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListview.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#Include <Array.au3>
#include<EditConstants.au3>
#include<GUIConstants.au3>
#Include <GuiListBox.au3>



Dim $array, $i, $file, $CountLines, $List1, $text
Global $aArray[1000]    

$Form1 = GUICreate("Form1", 718, 733, 230, 124)
;$List1 = GUICtrlCreateListView("", 165, 90, 250, 331)
$list1 = GUICtrlCreateList("", 165, 90, 250, 331)
$Button1 = GUICtrlCreateButton("start", 420, 395, 116, 31)


GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $Button1
            
    $Countfile= _FileCountLines("C:\Temp\samples.txt")

    $file = "C:\Temp\samples.txt"
    
For $i = 1 To $CountFile
    $var1= FileReadLine($file, $i)
$text = $text & @CRLF & $var1 
;_GUICtrlListBox_AddString($List1, $text)
Next

MsgBox(0,"test",$Text)
exit

            

    EndSwitch
WEnd

Share this post


Link to post
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
Sign in to follow this  
Followers 0