Computing.Net > Forums > Programming > VB 6 - trying to forma output files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VB 6 - trying to forma output files

Reply to Message Icon

Name: sooster
Date: March 3, 2008 at 20:54:41 Pacific
OS: Windows XP SP2
CPU/Ram: 2.0 GHz Centrino Duo / 2.
Product: Lenovo ThinkPad Z61t
Comment:

I have been working on a program that is taking a series of textbox fields (as entered by the user) and trying to have them output to a formatted text file.

I have been able to get the data output just fine, but it is far from readable format when I open the text file. Is there any way to do this?

I would like to at least be able to insert line breaks after each textbox is written to the file so it can be easily viewed.

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: March 4, 2008 at 02:19:53 Pacific
Reply:

I snippet of code to show exactly how you are writing the file would help then people would be able to tell you where you are going wrong.

Stuart


0

Response Number 2
Name: AlwaysWillingToLearn
Date: March 4, 2008 at 03:23:47 Pacific
Reply:

Try this,

Private Sub Stuff

Open ("A:\a.txt") For Output As #1
Print #1, "HHH"
print #1, Text1.text
Close #1
MsgBox "Done"

End Sub


0

Response Number 3
Name: sooster
Date: March 4, 2008 at 05:45:00 Pacific
Reply:

Here is the code I am trying to use. It works, but it does not format the output to the file. I would actually like to have each lable / text pair on one line by itself.

If fsys.FileExists(filename) Then
MsgBox "File exists... Appending new data to file"

Open filename For Append As #1
Print #1, Label1, Text1, Label2, Text2, Label3, Text3, Label4, Text4, Label; 5, Text5, Label6, Text6, Label7, Text7
Close #1
Else
MsgBox "Incident recorded" fsys.CreateTextFile filename

Open filename For Output As #1
Print #1, Label1, Text1, Label2, Text2, Label3, Text3, Label4, Text4, Label; 5, Text5, Label6, Text6, Label7, Text7
Close #1
End If


0

Response Number 4
Name: AlwaysWillingToLearn
Date: March 4, 2008 at 05:57:44 Pacific
Reply:

you can either have
Print #1, Labe11
print #1, Text1
etc

Or have

print #1, Lebel1 & vbcrlf, Text1 & vbcrlf

CRLF = Carriage Return Line Feed

which basically equates to a new line when you press enter either way would work


0

Response Number 5
Name: AlwaysWillingToLearn
Date: March 4, 2008 at 06:07:11 Pacific
Reply:

ok just tried it and there is one slight problem with the above, heres the correct way of using the VBCRLF code

Private Sub Stuff()

Open ("A:\a.txt") For Output As #1
Print #1, TextBox1.Text & vbCrLf & TextBox2.Text & Label2.Caption
Close #1
MsgBox "Done"

Text1.text = Hello
Text2.text= World
Label3.caption = Again

so when you open a.txt

you will have

Hello
World
Again

for the text and label pairs you have to do this

Open ("A:\a.txt") For Output As #1
Print #1, TextBox1.Text & " " & Label1.caption & vbCrLf & TextBox3.Text & " " & Label2.caption
Close #1
MsgBox "Done"


0

Related Posts

See More



Response Number 6
Name: StuartS
Date: March 4, 2008 at 06:40:42 Pacific
Reply:

If you are using so many controls why not use a control array. It makes the code so much easier.

dim a as Integer

Open filename For Append As #1

for a = 0 to 7
Print #1, Label1(a),
Print #1, Text1(a) & vbCrLf,
next
Close #1


Stuart


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB 6 - trying to forma output files

connecting to unix using vb 6.0 www.computing.net/answers/programming/connecting-to-unix-using-vb-60/7085.html

Visual Studio 2005 on VB 6.0 www.computing.net/answers/programming/visual-studio-2005-on-vb-60/13978.html

Trying to create C file and use my www.computing.net/answers/programming/trying-to-create-c-file-and-use-my-/12450.html