March 8, 2002 at 12:50 pm
Hi, All...
I have a q for U...as usual..
I want to add filler(I mean spaces) into the header text info..How can I do that instead of hitting spacebar? I need to add around 850 spaces into text header info...
Here is some code U can take a look it..
/*********************************/
Const ForReading=1, ForWriting=2, ForAppending=8
Dim fso, f, ReadDataFile, AppendToHeader,ReadTrailerFile,FinalFile
Dim dMonth, dDay, dTime,dMin
Set fso = CreateObject("Scripting.FileSystemObject")
'Create Text File & Insert Header Info
Set f = fso.CreateTextFile("c:\testfile.txt", True)
Select Case Len(Month(Date))
Case "1"
dMonth = "0" & Month(Date)
Case Else
dMonth = Month(Date)
End Select
Select Case Len(Day(Date()))
Case "1"
dDay = "0" & Day(date())
Case Else
dDay = Day(date())
End Select
Select Case Right(Time(), 2)
Case "AM"
dTime = "0" & Left(Time(), 1)
Case Else
dTime = Left(Time(), 1) + 12
End Select
Select Case Len(Replace(Time(), ":", ""))
Case "8"
dMin = Mid(Replace(Time(), ":", ""), 2, 4)
Case "9"
dMin = Mid(Replace(Time(), ":", ""), 3, 4)
End Select
dFiller=Char(849)
f.WriteLine("STKOPTHDR " & YEAR(DATE( )) & dMonth & dDay & dTime & dMin & " XOP1105" & dFiller)
f.Close
/*******************************/
All teh way bottom in dFiller position, I want to put filler(850 spaces)..
Any thought
Thx in advance
Jay
March 8, 2002 at 1:03 pm
Something like this shoulw work
DIM dFillStr, xLoop
FOR xLoop = 1 to 850
dFillStr= dFillStr & " "
NEXT
Once done you will have a variable with 850 whitespaces that you can just plug it.
Hope this helps.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
March 8, 2002 at 1:20 pm
Mannnn..U are great...
It works liek charm.. :-)))
How did U think about this? I was thinking more like putting some charater string instead of looping through..
Thx
Jay
March 8, 2002 at 3:38 pm
This is all I do all day, think about ways to do things to fix or improve our existing code. And I have had serveral situations where I needed 0 in the front of a number with a specific total length and this is pretty close to how I do those.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
March 8, 2002 at 3:42 pm
Space(850) works too.
March 8, 2002 at 3:50 pm
However those are SQL statements not VBScript.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
March 8, 2002 at 3:54 pm
my bad. vbscript not tsql.
Space(850) still works in vbscript.
Replace(character, number) becomes
Space(Number, character).
March 8, 2002 at 4:04 pm
Ok egg on my face, not seen those before, and they keep coming. I will have to check those out, thanks.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
March 11, 2002 at 7:33 am
Hey..hey..hey
U guys are having a ball without me..
Fill me in.. Kidding..
U know what.. I really grad that I can participate this discussion and I give my thanks to sqlservercentral and anybody who shares some knowledge with others..
Thx
Jay:-)))
March 11, 2002 at 1:46 pm
Well you know you should stay subscribed to your own post and as with any solution the first may work but may not be the best and keeping up with any future post may help you streamline your code.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply