From: LikeToCode on
I did not test the single date sorry!! However Richard's script will work
fine. In the Do While loop change
from:
Line = Replace(sLine, " ", " ")

To:
sLine = Replace(sLine, " ", " ")

Happy coding!
From: Pegasus [MVP] on


"Bill" <Bill(a)discussions.microsoft.com> said this in news item
news:0F3B395D-8BB9-47AA-ABAC-0CF8AF43E349(a)microsoft.com...
> I tried running this and it gets stuck in a loop somewhere (and pegs out
> my
> processor). It would definetly solve my issue with the single Feb day
> digit
> though.
>
> How can I see what's causing it to loop? All I did was past this code into
> a
> a VBS file and run it to see what it returnned.
>
> Thanks again for your help!
>

Silly typo in my code, which LikeToCode picked up. As he said, the code
should look like so:

sLine = "OR1363L3 Feb 4 2011 6:00PM"
Do While InStr(sLine, " ") > 0
sLine = Replace(sLine, " ", " ")
Loop
aLine = Split(sLine)
sKey = Replace(aLine(0), "L3", "", 1, - 1, 1) & " "
dDate = CDate(aLine(1) & " " & aLine(2) & " " & aLine(3))
WScript.Echo sKey & Pad(Month(dDate)) & Pad(Day(dDate)) & Year(dDate)

Function Pad (n)
Pad = Right("0" & n, 2)
End Function


From: LikeToCode on
"However Richard's script will work fine."

CORRECTION!!

However Pegasus's script will work fine.
Sorry Pegasus it must be all of the snow we are getting, can't seem to read
straight!

From: Bill on
Thank you very much for this!

I'm just having one last issue - in the first script you had the line:

strNew = strFileNumber & " " & strMonth & strDay & strYear

Which I was able to adapt to read the lines from my txt file.

But in pegasus' code it's:

WScript.Echo sKey & Pad(Month(dDate)) & Pad(Day(dDate)) & Year(dDate)

I tried changing the WScript.Echo to a vairable like this:

StrNew = sKey & Pad(Month(dDate)) & Pad(Day(dDate)) & Year(dDate)

But I got an error saying invalid syntax. How can I send the info to a
vairable instead of echo so i can read the lines from my txt file?



"Pegasus [MVP]" wrote:

>
>
> "Bill" <Bill(a)discussions.microsoft.com> said this in news item
> news:0F3B395D-8BB9-47AA-ABAC-0CF8AF43E349(a)microsoft.com...
> > I tried running this and it gets stuck in a loop somewhere (and pegs out
> > my
> > processor). It would definetly solve my issue with the single Feb day
> > digit
> > though.
> >
> > How can I see what's causing it to loop? All I did was past this code into
> > a
> > a VBS file and run it to see what it returnned.
> >
> > Thanks again for your help!
> >
>
> Silly typo in my code, which LikeToCode picked up. As he said, the code
> should look like so:
>
> sLine = "OR1363L3 Feb 4 2011 6:00PM"
> Do While InStr(sLine, " ") > 0
> sLine = Replace(sLine, " ", " ")
> Loop
> aLine = Split(sLine)
> sKey = Replace(aLine(0), "L3", "", 1, - 1, 1) & " "
> dDate = CDate(aLine(1) & " " & aLine(2) & " " & aLine(3))
> WScript.Echo sKey & Pad(Month(dDate)) & Pad(Day(dDate)) & Year(dDate)
>
> Function Pad (n)
> Pad = Right("0" & n, 2)
> End Function
>
>
From: Bill on
In case it helps here's what i have that's giving me the syntax error-

Dim fso, inF, outF, sLine
Set fso = CreateObject("Scripting.FileSystemObject")
Set inF = fso.OpenTextFile("myfile.txt", 1)
Set outF = fso.OpenTextFile("outfile.txt", 2, True)

Do Until inF.AtEndOfStream
sLine = inF.ReadLine

Do While InStr(sLine, " ") > 0
Line = Replace(sLine, " ", " ")
Loop
aLine = Split(sLine)
sKey = Replace(aLine(0), "L3", "", 1, - 1, 1) & " "
dDate = CDate(aLine(1) & " " & aLine(2) & " " & aLine(3))
StrNew = sKey & Pad(Month(dDate)) & Pad(Day(dDate)) & Year(dDate)

Function Pad (n)
Pad = Right("0" & n, 2)
End Function

outF.WriteLine StrNew
Loop









"Bill" wrote:

> Thank you very much for this!
>
> I'm just having one last issue - in the first script you had the line:
>
> strNew = strFileNumber & " " & strMonth & strDay & strYear
>
> Which I was able to adapt to read the lines from my txt file.
>
> But in pegasus' code it's:
>
> WScript.Echo sKey & Pad(Month(dDate)) & Pad(Day(dDate)) & Year(dDate)
>
> I tried changing the WScript.Echo to a vairable like this:
>
> StrNew = sKey & Pad(Month(dDate)) & Pad(Day(dDate)) & Year(dDate)
>
> But I got an error saying invalid syntax. How can I send the info to a
> vairable instead of echo so i can read the lines from my txt file?
>
>
>
> "Pegasus [MVP]" wrote:
>
> >
> >
> > "Bill" <Bill(a)discussions.microsoft.com> said this in news item
> > news:0F3B395D-8BB9-47AA-ABAC-0CF8AF43E349(a)microsoft.com...
> > > I tried running this and it gets stuck in a loop somewhere (and pegs out
> > > my
> > > processor). It would definetly solve my issue with the single Feb day
> > > digit
> > > though.
> > >
> > > How can I see what's causing it to loop? All I did was past this code into
> > > a
> > > a VBS file and run it to see what it returnned.
> > >
> > > Thanks again for your help!
> > >
> >
> > Silly typo in my code, which LikeToCode picked up. As he said, the code
> > should look like so:
> >
> > sLine = "OR1363L3 Feb 4 2011 6:00PM"
> > Do While InStr(sLine, " ") > 0
> > sLine = Replace(sLine, " ", " ")
> > Loop
> > aLine = Split(sLine)
> > sKey = Replace(aLine(0), "L3", "", 1, - 1, 1) & " "
> > dDate = CDate(aLine(1) & " " & aLine(2) & " " & aLine(3))
> > WScript.Echo sKey & Pad(Month(dDate)) & Pad(Day(dDate)) & Year(dDate)
> >
> > Function Pad (n)
> > Pad = Right("0" & n, 2)
> > End Function
> >
> >
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Running ASP Page.
Next: SQL Version (Build) with WMI