Computing.Net > Forums > Programming > Razor...I figured out my VBScript

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Razor...I figured out my VBScript

Reply to Message Icon

Name: skisalomon77
Date: July 29, 2008 at 14:08:10 Pacific
OS: XP Pro
CPU/Ram: Intel/2GB
Product: Dell
Comment:

Hey Razor,

I figured out my script to string the bytes together into a new file.

Previously, I was reading a single file that already contained a set of exported data, searching for specific data in that file, and stringing everything together in a new file, but here my script was stringing everything together incorrectly.

Now, I'm opening/reading every file in a specific directory, looking for specific data in each file, then stringing that data together into a new file. I've been testing it out and I'm getting exactly what I need now.

Just wanted to let you know that I didn't give up on it.

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set FileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\ArchivedSANEW'} Where " _
& "ResultClass = CIM_DataFile")

For Each objFile In FileList
strName = objFile.FileName

Set objFile = objFSO.OpenTextFile(objFile.Name, ForReading)
strContents = objFile.ReadAll
objFile.Close

strContents = Replace(strContents, "~", "~" & vbCrLf)

arrLines = Split(strContents, vbCrLf)

For Each strLine in arrLines
If Left(strLine, 3) = "000" Then
StoreNumber = Mid(strLine, 6, 3)
TransNumber = Mid(strLine, 29, 6)
TransDate = Mid(strLine, 35, 8)
TransCancel = Mid(strLine, 52, 1)
TransType = Mid(strLine, 47, 3)
End If

If Left(strLine, 3) = "021" Then
DiscountCode = Mid(strLine, 4, 8)
AmountBeforeDiscount = Mid(strLine, 12, 10)
DiscountAmount = Mid(strLine, 22, 10)
AmountAfterDiscount = Mid(strLine, 32, 10)
End If

If Left(strLine, 3) = "028" Then
CoupCode = Mid(strLine, 14, 40)
strNewFile = strNewFile & StoreNumber & TransNumber & TransDate & TransCancel & TransType & _
DiscountCode & AmountBeforeDiscount & DiscountAmount & AmountAfterDiscount & CoupCode & VbCrLf
End If

If Left(strLine, 3) = "077" Then
OriginalTransNumber = Mid(strLine, 4, 6)
strNewFile = strNewFile & StoreNumber & TransNumber & TransDate & TransCancel & TransType & _
" " & OriginalTransNumber & VbCrLf
End If
Next

Set objFile = objFSO.CreateTextFile("C:\ArchivedSANEW\CouponCode.txt")
objFile.Write strNewFile
objFile.Close

Next



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Razor...I figured out my VBScript

Add new file extensions to registry www.computing.net/answers/programming/add-new-file-extensions-to-registry/9106.html

passing parameters (assembly) www.computing.net/answers/programming/passing-parameters-assembly/14119.html

php multi counter www.computing.net/answers/programming/php-multi-counter/8817.html