Count and Pad String

  • Thread starter Thread starter Sash
  • Start date Start date
S

Sash

I have a program that does a lot of stuff and after running through a lot of
criteria and data formatting, I writ the string to a file as follows stType1
being declared as as string:

Print #1, stType1

My probem is that I need to see how many characters are in that string and
pad the end to equal 550.

So it would basically be:

intCount = 550 - (the length of stType1--however I do that)

and instead of the above I would do

Print #1, stType1 & String(inCount, Chr(32))

Any help would be greatly appreciated!!!!
 
Sash said:
I have a program that does a lot of stuff and after running through a lot
of
criteria and data formatting, I writ the string to a file as follows
stType1
being declared as as string:

Print #1, stType1

My probem is that I need to see how many characters are in that string and
pad the end to equal 550.

So it would basically be:

intCount = 550 - (the length of stType1--however I do that)

and instead of the above I would do

Print #1, stType1 & String(inCount, Chr(32))

Any help would be greatly appreciated!!!!


The Len() function returns the length of a string. You could write:

Print #1, stType1; String(550 - Len(stType1), " ")
 
Sash said:
I have a program that does a lot of stuff and after running through a lot
of
criteria and data formatting, I writ the string to a file as follows
stType1
being declared as as string:

Print #1, stType1

My probem is that I need to see how many characters are in that string and
pad the end to equal 550.

So it would basically be:

intCount = 550 - (the length of stType1--however I do that)

and instead of the above I would do

Print #1, stType1 & String(inCount, Chr(32))

Any help would be greatly appreciated!!!!

You can declare a fixed-length string 550 characters wide, like this:

Dim MyString As String * 550

At this point MyString contains 550 space characters. Then if you just
assign 10 characters:

MyString = "1234567890"

Mystring will then contain those 10 chars, plus 540 spaces.
 
Back
Top