[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

Printing a text file in a textbox

Need code that will print a text file in a textbox when a node in treeview is clicked.  Also,is listview or textbox more appropriate for this?

1 Solution
TreeView Click Event
   open text file
   read data to string
   close text file
   TextBox1.Text = string
End click event

TreeView/ListView will depend on what the text file looks like.  More than likely it has multiple lines in it, so the textbox would be more appropriate (just make sure the textbox is setup as multiline and you read the file in binary mode to keep the CR/LF)

Unless you want to edit the text, I would suggest doing this to a label.  The string will run of the end, while the label will act more like a text file, and print the text on the next line of the label when it reaches the end.

same as above except use

Label1.Caption = String

Hope this is of use
Dear aijohn,

th code for putting the entire content of the text file to the text box is:

Private sub GetFile(byval strFile as string)
   dim strContents
   on error goto ErrHandler
   Open strFile For Input As #1
        strContents = Input(LOF(1), #1)
   Close #1

   Text1.text = strcontents
   Exit sub

   msgbox "error occured"
End sub

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now