?
Solved

Printing a text file in a textbox

Posted on 2003-02-20
3
Medium Priority
?
178 Views
Last Modified: 2010-05-01
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
Comment
Question by:aijohn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
FRoeCassNet earned 160 total points
ID: 7991389
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
 
LVL 2

Expert Comment

by:Jacamar
ID: 7991435
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
 
LVL 3

Expert Comment

by:vbbuff
ID: 7991477
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question