Horizontal Spacing Text File (1 Viewer)

ProgramRasta

Member
Local time
Today, 08:46
Joined
Feb 27, 2020
Messages
98
Hello All,

I was wondering is it possible to adjust the horizontal spacing in a newly created text file. Each of the table columns is separated by a space - what I am trying to achieve is to increase the length of the space. Importantly, the format has to remain unchanged i.e. it needs to remain one space.

Code:
Set rstTableToExportRecords = dbs.OpenRecordset(strTable, dbOpenDynaset)

Set fsoFileSystem = New Scripting.FileSystemObject

Set tsoTextFile = _
fsoFileSystem.CreateTextFile(strFullFilePath & strExportFile, True, False)

strFieldDelimiter = " "

Do Until rstTableToExportRecords.EOF
    strTextFileRow = ""
    For Each fld In rstTableToExportRecords.Fields
        strTextFileRow = strTextFileRow & rstTableToExportRecords(fld.Name) & strFieldDelimiter
    Next fld
    If Len(strTextFileRow) = 0 Then
    Else
        If Right(strTextFileRow, 1) = strFieldDelimiter Then
            strTextFileRow = Left(strTextFileRow, (Len(strTextFileRow) - 1))
        Else
        End If
    End If
    tsoTextFile.WriteLine (strTextFileRow)
    rstTableToExportRecords.MoveNext
Loop

Thanks for your time
 

Minty

AWF VIP
Local time
Today, 08:46
Joined
Jul 26, 2013
Messages
10,371
I'm afraid I'm very confused;
A single space is exactly that 1 x " "

How can it be 'bigger' ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:46
Joined
Sep 21, 2011
Messages
14,370
Use a TAB character?
 

ProgramRasta

Member
Local time
Today, 08:46
Joined
Feb 27, 2020
Messages
98
I'm afraid I'm very confused;
A single space is exactly that 1 x " "

How can it be 'bigger' ?
I clearly didn't explain the problem too well!

The output is the following:

Field1 Field2 Field3...

I want the output to be

Field1 Field2 Field3

As above more horizontal spacing but using a single space. Is there any way to increase the width of the space to say a tab?

It's probably a stupid question, I was unable to find anything online to point me in the right direction.

Thanks for your time.
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:46
Joined
Sep 21, 2011
Messages
14,370
You swap the space for a tab character?
 

Minty

AWF VIP
Local time
Today, 08:46
Joined
Jul 26, 2013
Messages
10,371
As per @Gasman try using a tab character

strFieldDelimiter =Chr(9)
 

sonic8

AWF VIP
Local time
Today, 09:46
Joined
Oct 27, 2015
Messages
998
As above more horizontal spacing but using a single space.
?!
This is simply not possible. If your specification requires columns to be separated by a single space you can neither replace it by something else (TAB) nor can you make a single space wider than a single space.
 

isladogs

MVP / VIP
Local time
Today, 08:46
Joined
Jan 14, 2017
Messages
18,247
Not sure I follow either but perhaps consider using a monospaced font like Courier New
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:46
Joined
Feb 19, 2002
Messages
43,374
A file is something that is read by the computer. That is why the format requirement is so specific. It is not intended to be read by humans so why do you even care how "wide" the space is? If you want to view the file, use a form or a report. Those are what we use to interact with humans, not raw files!

In a monospaced font like courier (which you can change the font used to view the file) ALL characters take up the same amount of space. With a proportional font, each character takes up the amount of space it needs and a space is the size of a medium character. But as far as the file is concerned, a byte is a byte is a byte.
 

Users who are viewing this thread

Top Bottom