|
-
Jun 26th, 2000, 02:06 AM
#1
Thread Starter
Lively Member
I have couple data I want to save it into a txt file, but it's very hard to aligh it, because the length of data are different, so I am thinking if I can fix the length of them, it will be much easier to format my txt file.
like fix length to 10:
"John" will become "John "
add space to it.
is there any function can do this?
or do you have better sugestions?
Thanks
Cerebrate
-
Jun 26th, 2000, 02:13 AM
#2
Frenzied Member
Hasn't this already been anwered in the VB-General forum?
you could do somthing like this to pad out teh sring with spaces:
Code:
strTemp = left(strTemp & space(10),10))
-
Jun 26th, 2000, 02:35 AM
#3
Junior Member
Use "* 10" to fix the len of a string to 10 chr. Then when you use Put and Get to read and write.
'Save Info
Dim sOutput as String * 10
Open aFile for Output as #1
Put #1 ,sOutput
Close #1
'Read Info
Dim sInput as String * 10
Open aFile for Input as #1
Get #1,, sInput
Close #1
-
Jun 26th, 2000, 04:10 AM
#4
Thread Starter
Lively Member
I know..
sorry about double posting..
the reason I post this Q here again is because this is for my web page, not VB application, so some function cannot be used in VBScript, such as Format$,
and....... I believe I cannot Dim some variable as String in VBScript. right? all variables are declared as variant.
can I do this "Dim str as String" in VBScript?
thanks for all help.
actually, I write a function myself for this Q.
-----------------------------------------------------
fixStrLen = dataStr & string(size - len(dataStr)," ")
-----------------------------------------------------
"size" is the size of string you want to be fixed
"dataStr" is the origional string.
Cerebrate
-
Jun 26th, 2000, 03:10 PM
#5
Frenzied Member
The plot thickens....
But why do you want to pad strings with spaces on a html page?
unless used within <pre> tags, the browsers reduce all spaces to one space.
Just tell me to mind my own business if you like! 
-
Jun 26th, 2000, 11:12 PM
#6
Thread Starter
Lively Member
I want to store couple data to a txt file and then email it to someone, so with fixed string, it will be nice and neat to read.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|