[Webinar] Streamline your web hosting managementRegister Today

x
  • 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?

Thanks
0
aijohn
Asked:
aijohn
1 Solution
 
FRoeCassNetCommented:
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)

0
 
JacamarCommented:
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
0
 
vbbuffCommented:
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

ErrHandler:
   msgbox "error occured"
End sub
0

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