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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

only printing values to output file if not empty

Status
Not open for further replies.

impulse24

IS-IT--Management
Jul 13, 2001
167
US
Hi Everyone,

I have a program that opens a fixed width text file, and i assign values to variables based on the position. I then print the values back to a second text file, and put in a delimiter.

Here is my code below:
Open txtfilename For Input As #1
Open txtfilename & ".new" For Append As #2
Do Until EOF(1)
Line Input #1, Data
strTDeedNum = Left(Data, 11)
strTDEEDTYPE = Trim(Mid(Data, 12, 40))
strTGFName = Trim(Mid(Data, 52, 20))
Print #2, strDeedNum & "|" & strDEEDTYPE
Loop
close #1
Close #2

How do I make it so that if a variable is empty, I don't print it back to the new text file.

I am printing all values on one line.

Please help.
 
I know to use the if variable = "" Then
print statement.

With the above method, the variables are printed out on a new line

But since I have all the variables on one line, and the input file may have one variable and not the others this won't work

Here is the input:

12345 ten 80
56789
nine90

Here would be the output I am looking for:
12345,ten,80
56789
nine,90

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top