Link to home
Start Free TrialLog in
Avatar of JohnDoeSr
JohnDoeSr

asked on

Would like to Print 2nd dimension of array on the 50th position of its line in .txt file

I'm saving off both parts of a 2 dimensional array onto a text file like so:

Open FileNameSave$ For Append As #2
For tt% = LastSave& To i%
    Print #2, EmailnPw$(tt%, 1) & ";" & EmailnPw$(tt%, 2)     - Email being (1,1) and PW being (1,2)
Next
Close #2

Each Email PW will be placed on its own line in the text file
I'd like to have the PWs line up in a nice column. The email will easily do this since it's placed on the first position of its line. I could easily add a TAB between email & pw but that will not guarantee me that the PW will be placed in the same position of the line since email lengths can vary.

What I'd like to do is something like place the PW on the something like the 50th position of its line, regardless of the length of the email address. Not 50 spaces AFTER the email has ended but 50th position from the start of the line. This way, if the length of an email address is 10 characters or 40, the pw will always be in the 50th position. The main objective here is to have a nice column of both email addresses and passwords like so:

john@frank.com                     pass1
sing@songsforboe.com           pass2
joe@joe.com                         pass3
ASKER CERTIFIED SOLUTION
Avatar of jkaios
jkaios
Flag of Marshall Islands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you plan to remove the semi-colon (";") as the separator between the email address and the password, then
simply increase the length of the string from 48 to 49 as follows:

========================================
   Print #2, PadR(EmailnPw$(tt%, 1), 49) & EmailnPw$(tt%, 2)
========================================

This will print the email address (padded with spaces up to the 49th column/position).  Therefore, the next printed text, which is the password, will ALWAYS be on the 50th column or position within the text file.

Cheers!
Avatar of JohnDoeSr
JohnDoeSr

ASKER

Works like a charm.

Thanks!