Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with textbox

Status
Not open for further replies.

sborny

Technical User
Jun 29, 2001
157
0
0
GB
Hi,

I have an app that creates a text file at the begining and the appends to it as the app goes along.

At the end I have a form with a text box on it with multi line set to true.

I then open the completed text file into the textbox but it only shows me the last line that was appended to the text file.

any ideas waht i am doing wrong.

Cheers

Symon.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
I don't know what is the problem with the text box, but you can use Rich Text Box and set the FileName property to the txt file, you want to display and it will load & show the whole file.

For example:
Put RTB on the form and write in the form_load event

with rtb
.filename="c:\MyFile.txt"
.refresh
end with


Hope this helps
Mangro
 
Close the file after each write. I had the same problem with an error log file. It would not show me the last lines before the program crashed, Which was obviously what I needed.

Now I do something Like this...

Private Sub Command1_Click()
Const MyName = "Command1"

WriteTrace, MyName, "Write this text to a file"
End Sub

Public Sub WriteTrace(sRoutine As String, sMessage As String)

' Open the file
' Write to the file
' Close the file.

Craig

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
You can open the file, read the file first in a string var and then
txtBox.Value = stringVarFrom File

You can access the file using FileSystemObject.

Success.
 
sborny, without seeing the relevant parts of your code is is difficult to see what you are doing wrong. Post some code and we will have a look.

Thanks and Good Luck!

zemp
 
Cheers Everyone.

I have managed to get the file open in to a Rich Text Box but it also includes the Speech Marks around each line does anyone know how to get rid of them.

Here is the original code I used wjen I was having the problem with only one line showing.

Please have a look at this as I may need to use this anyway.


This code is in the form load sub.

Open (App.Path + "\report.dat") For Input As #1
Do Until EOF(1)
Input #1, Data
Text1.Text = Data
Loop
Close #1

I have not put the rest of the code as it is appending the file and everything is there so I gather that the problem lies when I open the file for input.

Thanks again.

Symon.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
Probably dumb comment to throw in this thread but is your textbox Multiline property set to true? I've made that error before....

Just my 2 cents and thats all your getting...is the day over yet?
 
RobcTech,

Thanks anyway, but my original post says that I had set it to true.

Thanks for replying though.

Cheers

Symon.

Everything has an answer, it's just knowing the right question to ask. !!!!
 
um

Code:
Text1.Text = Data

each time through the loop, the text box gets overwritten by the new line...

no suprises there!
try
Code:
Text1.Text = Text1.text & Data

i.e. add the contents of Data to text1.text


Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Okay so i am a complete idiot.

Something so simple tha I missed it.

Now how do I get each line to be on a seperate line and not just following on from the last.

cheers

Symon.


Everything has an answer, it's just knowing the right question to ask. !!!!
 
Try adding the carriage return character after each entry.

Text1.Text = Text1.text & Data & vbCrLf

This will leave an extrs Carriage return character in the text box, but I am sure that you can handle removing that if you want.

Thanks and Good Luck!

zemp
 
>Okay so i am a complete idiot.

I spent a while trying to solve similar problem only today



Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top