Results 1 to 9 of 9

Thread: Tab?

  1. #1
    vbjohn
    Guest

    Exclamation 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-

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    use the ascii scan code 9 - converts to the tab character

  3. #3
    Lively Member
    Join Date
    Aug 2001
    Location
    Crossroads of America
    Posts
    72
    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.

  4. #4
    vbjohn
    Guest

    Exclamation 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....

  5. #5
    Addicted Member Dim A's Avatar
    Join Date
    Jul 2000
    Posts
    201

    have you tried?

    VB Code:
    1. txtfile.Write Tab(10) & Trim(DEnv.rscmdDFC.Fields("SOCSCNUM").Value)

    might work...

    - Dim A

  6. #6
    Lively Member
    Join Date
    Aug 2001
    Location
    Crossroads of America
    Posts
    72
    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>

  7. #7
    vbjohn
    Guest

    Question 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.

  8. #8
    Addicted Member Dim A's Avatar
    Join Date
    Jul 2000
    Posts
    201
    Try defining a bunch of fixed length strings and using rset and lset...

    VB Code:
    1. dim strLName as string *15
    2. dim strFName as string *15
    3.  
    4. lset strLName=lName & ","
    5. lset strFName=fName
    6.  
    7. debug.print strLName & strFname

  9. #9
    Lively Member
    Join Date
    Aug 2001
    Location
    Crossroads of America
    Posts
    72
    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
  •  



Click Here to Expand Forum to Full Width