I am a newbie using VB6 to try to create a basic text file program. Mostly in my work, I create a lot of text files with headers and then with variable data to save me manually by typing a document with each heading every time I created a VB6 program that automatically added headers, I would enter the data and it would be display all this as a text file. I have done most of this, but there is one part that I cannot do.
One part of a text file is a numbered list with a dot after it. EG:
TITLE
01. CHEESE
02. CHOCOLATE
03. BREAD
etc.
The list is different in each file and has a different length, so there can be 4 elements, maybe 20. At the moment I just got a plain text block, and I manaully enter the data every time, as indicated above, with numbers, I would like so that the number, point and space are automatically created in front of the list. So I could just enter a list like
CHEESE
CHOCOLATE
BREAD
and when I generate a text file, the list will be automatically numbered. Is this possible with VB6? I know this sounds like a small detail, but I create hundreds of these files, and the less effort I can do for each, the better.
Private Sub create_Click()
Dim fso
Dim file As String
file = "C:\Textfile.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file) Then
fso.DeleteFile file, True
End If
Const ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile("C:\Textfile.txt", ForAppending, True)
With filetxt
.writeline (txtArtist & vbNewLine)
.writeline ("SOURCE" & " (" & Combo1 & " #" & txtsource & ")" & ":")
.writeline (txtequip & vbNewLine)
.writeline (Combo2 & ":")
.writeline (txttransfer & vbNewLine)
.writeline ("GENERATION:")
.writeline (txtgen & vbNewLine)
.writeline ("LENGTH:")
.writeline (txtlength & vbNewLine)
.writeline ("NOTES:")
.writeline (txtnotes & vbNewLine)
.writeline ("TRACKS:")
.writeline (txttracks & vbNewLine)
.writeline ("MD5 FINGERPRINTS:")
.writeline (txtmd5 & vbNewLine)
.writeline ("TRANSFERRED BY:")
.writeline (txttransferby & vbNewLine)
.writeline ("**PLEASE DO NOT ENCODE TO LOSSY FORMATS OR SELL!**")
.Close
End With
Shell "notepad.exe C:\Textfile.txt", vbNormalFocus
End Sub
source
share