Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Parsing file in DTS Package Expand / Collapse
Author
Message
Posted Thursday, March 13, 2014 3:27 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, August 1, 2014 2:06 AM
Points: 14, Visits: 123
I have to parse the following lines. I need a detailed explanation of how the functions and operators are working together to find the dates. First time with VB.



LOT!99!AA!!999999!19990101!!!!!19990102
LOT!01!AA!!999998!19990101!!!!!19990102
LOT!03!AA!!999997!19990101!!!!!19990102
LOT!99!AA!!999996!19990101!!!!!19990101
SAD!99!AA!!999995!19990101!!!!!19990101






''''''''''''""""""""""""""""""""""""""Open the Modified LOT for reading""""""""""""""""""""""""""""""""""""""""""""""""
Function Parse(c_strLOTFile)

strMsg = "Opening LOT data file for reading."
AddFileLogLine strMsg

'reads text file line by line
Do Until LOTFileOpen.AtEndOfStream
strTemp = LOTFileOpen.ReadLine

Const c_strLOT = "LOT"
''''''''''"""""""""""""""""""""""""""""" LOT Line """"""""""""""""""""""""""""""""""""""""""""""""
Dim strDelim 'Character used as delimiter
Dim strTOWNo 'TOW Number
Dim dteLOTDate 'LOT Date
Dim dteTOWDate 'TOW Date
Dim strLOTLoc01 'LOT01 location
Dim strLOTLoc02 'LOT02 location
Dim strLOTLoc03 'LOT03 location
Dim strLOTLoc04 'LOT04 location
Dim strLOTLoc05 'LOT05 location
Dim strLOTLoc06 'LOT06 location
Dim strLOTLoc07 'LOT07 location
Dim strLOTLoc08 'LOT08 location
Dim strLOTLoc09 'LOT09 location

Dim dblcount
dblcount = Null
dblcount = 1

'Set delimiter to !
strDelim = "!"

Case (Left(strTemp, 3) = c_strLOT) 'Start of Beginning Segment for LOT

'Resets values to Null
strTOWNo = Null
dteLOTDate = Null
dteTOWDate = Null
strLOTLoc01 = Null
strLOTLoc02 = Null
strLOTLoc03 = Null
strLOTLoc04 = Null
strLOTLoc05 = Null
strLOTLoc06 = Null
strLOTLoc07 = Null
strLOTLoc08 = Null
strLOTLoc09 = Null

'find all delimiter locations
strLOTLoc01 = Instr(strTemp, strDelim) + 1
strLOTLoc02 = Instr(strLOTLoc01, strTemp, strDelim) + 1
strLOTLoc03 = Instr(strLOTLoc02, strTemp, strDelim) + 1
strLOTLoc04 = Instr(strLOTLoc03, strTemp, strDelim) + 1
strLOTLoc05 = Instr(strLOTLoc04, strTemp, strDelim) + 1
strLOTLoc06 = Instr(strLOTLoc05, strTemp, strDelim) + 1
strLOTLoc07 = Instr(strLOTLoc06, strTemp, strDelim) + 1
strLOTLoc08 = Instr(strLOTLoc07, strTemp, strDelim) + 1
strLOTLoc09 = Instr(strLOTLoc08, strTemp, strDelim) + 1



strTOWNo = Mid(strTemp, strLOTLoc03, 7)

dteTOWDate = Trim(Mid(strTemp, (strLOTLoc04 + 4), 2) &"/"&Mid(strTemp, (strLOTLoc04 + 6), 2) &"/"&Mid(strTemp, strLOTLoc04, 4))

dteLOTDate = Trim(Mid(strTemp, (strLOTLoc09 + 4), 2) &"/"&Mid(strTemp, (strLOTLoc09 + 6), 2) &"/"&Mid(strTemp, strLOTLoc09, 4))

'running count of segments
dblcount = (dblcount + 1)

End Select
Loop

Post #1550584
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse