Hi,
I need to read-in contents of a text file (Readme file) into a text box on my Help.frm. What would be the right approach? Can anyone help?
Thanks.
Printable View
Hi,
I need to read-in contents of a text file (Readme file) into a text box on my Help.frm. What would be the right approach? Can anyone help?
Thanks.
Maybe this code helps you. :)
Code:Dim oneLine As String 'one line of the file
'open the file
Open "c:\myfile.txt" For Input As #1
'read each line and add it to the textbox
Do
'read a line
Line Input #1,oneLine
'add it to the textbox
Text1.Text = Text1.Text & oneLine & VBCRLF
Loop Until Eof(1)
'close the file
Close #1
Maybe you should cosider using a RichTextBox control. It does whatever a regular Textbox would do but even better. If your help text file is very long you should use a RichTextBox.
Code:RichTextBox1.LoadFile "C:\MyTxtFile.txt", 1
The size limit of a textbox is 64 KB, so I don't think you need a richtextbox. But a richtextbox also supports formatting.
The RTF Box uses up a lot more resources than a standard Textbox.
Here is a faster way of loading the file. (using a standard TextBox)
Code:Open "MyFile.txt" For Input As #1
Text1 = Input(LOF(1), 1)
Close #1
well, what is the limit in size for a rtb?
Wengang
The limit for a RTF box is the virtual memory that Windows has assigned your program.
That is it doesn't have a limit other than the RAM.
thanks