Jump to content
Sign in to follow this  
Silvinho

Do type values in the edit reading her a txt file?

Recommended Posts

Silvinho

How to type a value in an edit from the data of a file txt?.

thank's

Share this post


Link to post
Share on other sites
McGod

#include <GUIConstants.au3>
$Form1 = GUICreate("Import File to Editbox", 633, 454, 193, 115)
$Edit1 = GUICtrlCreateEdit("", 8, 32, 617, 417)
$Button1 = GUICtrlCreateButton("Import File to Edit box", 160, 0, 305, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Local $sFile = FileOpenDialog("Import File", @ScriptDir, "All (*.*)")
            ImportToEdit($Edit1, $sFile)
    EndSwitch
WEnd


Func ImportToEdit($Edit, $File)
    Local $sInfo = FileRead($File, FileGetSize($File))
    If @error Then Return
    GUICtrlSetData($Edit, $sInfo)
    Return
EndFunc

Try that, it will read a file and put the contents into a edit box. I put the actual code into a function so it's "portable".

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  

×