I have added spaces to fields of data pulled from a database, but I'm having problems applying this principal to items read from a text file.
My objective is to add spaces to shorter items, like: "TOM JONES________________"=25, "MAXAMILLION HEIDELBURG___"=25 (space=_)
Using data tables, this worked:
But in my text array, I don't have specific fields:
Any suggestions appreciated.
My objective is to add spaces to shorter items, like: "TOM JONES________________"=25, "MAXAMILLION HEIDELBURG___"=25 (space=_)
Using data tables, this worked:
Code:
sTemp = RS.Fields("Groups") & Space(15 - Len(RS.Fields("Groups")))
sTemp1 = RS.Fields("BitLabel") & Space(17 - Len(RS.Fields("BitLabel")))
List2.AddItem Format(RS.Fields("BitID"), "00") & " " & sTemp & vbTab & sTemp1 & vbTab & RS.Fields("Time_On")
Code:
Open "C:\TestFile2.Txt" For Input As FileNumber
' read each line in the file, until we've read them all
Do While Not EOF(FileNumber)
FormattedData = "" ' clear the temp string
Line Input #FileNumber, FileData ' read the entire liine from the file
DataArray = Split(FileData, ",") ' seperate the values based onthe comma
' loop through the split up data in the array
For LoopCounter = 0 To UBound(DataArray)
' strip off double quotes, vbTab for new column
FormattedData = FormattedData & Replace(DataArray(LoopCounter), Chr(34), "") & vbTab
Next LoopCounter
lstData.AddItem FormattedData ' add formatted data to listbox
Loop
Close FileNumber