|
-
Jun 27th, 2002, 09:20 AM
#1
Tab?
Is there some sort of a TAB function in VB 6.0?
Cause I need to write data to a text document on the harddrive and the data needs to be in certain positions. For some reason I thought there was but I am not sure how it went. If anyone has any examples please let me know.
Thanks,
John-
-
Jun 27th, 2002, 09:29 AM
#2
use the ascii scan code 9 - converts to the tab character
-
Jun 27th, 2002, 09:30 AM
#3
Lively Member
if you're using the old open/print # to open and write the text file, you can use the tab() function:
Print #filenumber, [outputlist]
The outputlist argument settings are:
[{Spc(n) | Tab[(n)]}] [expression] [charpos]
Setting Description
Spc(n)
Used to insert space characters in the output, where n is the number of space characters to insert.
Tab(n)
Used to position the insertion point to an absolute column
number, where n is the column number. Use Tab with no argument to position the insertion point at the beginning of the nextprint zone.
expression
Numeric expressions orstring expressions to print.
charpos
Specifies the insertion point for the next character. Use a semicolon to position the insertion point immediately after the last character displayed. Use Tab(n) to position the insertion point to an absolute column number. Use Tab with no argument to position the insertion point at the beginning of the next print zone. If charpos is omitted, the next character is printed on the next line.
don't know about the new FSO object that microsoft wants everybody to use.
-
Jun 27th, 2002, 09:47 AM
#4
hmmm
I tried using the TAB() function but it does not work at all.
This is my code so far...
Dim File As String
Dim fso, Name
Dim txtfile
File = "C:\" & "DFCEMP.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfile = fso.CreateTextFile(File, True)
'Writes all the files to the text file DFCEMP.txt
Do Until DEnv.rscmdDFC.EOF
txtfile.Write Chr$(34)
txtfile.Write Trim(DEnv.rscmdDFC.Fields("SOCSCNUM").Value)
txtfile.Write Chr$(34)
DEnv.rscmdDFC.MoveNext
Loop
What I need to do is instead of doing it like this.....
txtfile.Write Trim(DEnv.rscmdDFC.Fields("SOCSCNUM").Value)
I would need to do something like this.....
txtfile.Write Tab(10); Trim(DEnv.rscmdDFC.Fields("SOCSCNUM").Value)
Thanks....
-
Jun 27th, 2002, 09:56 AM
#5
Addicted Member
have you tried?
VB Code:
txtfile.Write Tab(10) & Trim(DEnv.rscmdDFC.Fields("SOCSCNUM").Value)
might work...
- Dim A
-
Jun 27th, 2002, 09:57 AM
#6
Lively Member
since you're using the FSO, you'll have to do things a little differently.
From looking at your code, it looks like you just need your data to start in column 11. Two ways to do this...simple and complicated.
<code>
' -- Simple --
txtfile.Write Space(10); Trim(DEnv.rscmdDFC.Fields("SOCSCNUM").Value)
' -- Complicated --
' use this method if you have variable-length stuff
' being written to the same line prior to this value
txtfile.Write Space(10-txtfile.Column); Trim(DEnv.rscmdDFC.Fields("SOCSCNUM").Value)
</code>
-
Jun 27th, 2002, 10:06 AM
#7
well...
Well... There is more data that needs to be in the file...
SSN = tab(2)
LName = tab(27)
FName = tab(45)
MName = tab(58)
So I am not sure that the Space() function would work on that.
-
Jun 27th, 2002, 11:54 AM
#8
Addicted Member
Try defining a bunch of fixed length strings and using rset and lset...
VB Code:
dim strLName as string *15
dim strFName as string *15
lset strLName=lName & ","
lset strFName=fName
debug.print strLName & strFname
-
Jun 27th, 2002, 11:56 AM
#9
Lively Member
vbjohn, space() should still work if you use the second method i mentioned. Try something like this:
Code:
Dim File As String
Dim fso, Name
Dim txtfile
File = "C:\" & "DFCEMP.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfile = fso.CreateTextFile(File, True)
'Writes all the files to the text file DFCEMP.txt
Do Until DEnv.rscmdDFC.EOF
txtfile.Write Chr$(34)
txtfile.write space(2); Trim(DEnv.rscmdDFC.Fields("SSN").Value)
txtfile.write space(27-txtfile.column); Trim(DEnv.rscmdDFC.Fields("LName").Value)
txtfile.write space(45-txtfile.column); Trim(DEnv.rscmdDFC.Fields("FName").Value)
txtfile.write space(58-txtfile.column); Trim(DEnv.rscmdDFC.Fields("MName").Value)
.
.
.
txtfile.Write Chr$(34)
DEnv.rscmdDFC.MoveNext
Loop
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|