Okay. In the below Sub, sqlAddHeaders(), its nearly working.
I have a file in the form :
Code:
791755	Backup Solutions|Backup Software|Computer Associates	BrightStor Arcserve Backup Version 9 Tape Raid Option for Netware		506		Product Information	BABFBNW900NE2	0	0
791772	Backup Solutions|Backup Software|Computer Associates	BrightStor Arcserve Backup Version 9 Tape Library Option for Netware		455		Product Information	BABFBNW900NE4	0	0
872095	Backup Solutions|Backup Software|Computer Associates	BrightStor Arcserve Backup Version 9 Universal Client Agent for windows Upgrade from any previous evrsion 		69		Product Information	BABWUP2900E22?BDL	122	0
702346	Backup Solutions|Backup Software|Computer Associates	OLP BrightStor ARCserve for Small Business Server 2000 with Open Files Agent 2 Year Upgrade Protection		231		Product Information	ARCBBN2700WG0U2	0	0
804202	Backup Solutions|Backup Software|Veritas	Backup Exec,Windows,Microsoft Exchange Server Agent Upgrade,v9.0,E/F/G/S/I/C,Full Package Product 		114		Product Information	E094018	0	14
749605	Backup Solutions|Backup Software|Veritas	NetBackup BusinesServer NDMP Agent version 4.5, Cross Platform		1043		Product Information	A08587C-000000	0	0
755887	Backup Solutions|Backup Software|Veritas	Netbackup BusinesServer Exchange Agent version 4.5 VS1 12x5 1yr		144		Product Information	W085805-000112	0	0
I'm passing 2 parameters into the sub, namely, strData (which is the 2nd field above (Backup Solutions|Backup Software|Veritas)), and strChildSAPCode, eg. 791755

Now. I am them reprinting the info back out using a logging function at the bottom. It works fine for all the Computer Associates fields. But once it hits veritas, its not working.
Here's an example:
Code:
Backup Solutions:Backup Software:Computer Associates:791755
Backup Solutions:Backup Software:Computer Associates:791755791772
. . . 
::Veritas:804202
::Veritas:804202749605
So. Why is it storing all the infomation correctly, until the first time the 3rd section in the 2nd field changes...?

VB Code:
  1. Imports System.Data.SqlClient
  2.  
  3. Module modMisc
  4.  
  5. #Region "Declarations ..."
  6.     Private blnHaveCleared As Boolean
  7.  
  8.     Private colMasterHeaders() As clsColumnReference
  9.     Private colSecondHeaders() As clsColumnReference
  10.     Private colThirdHeaders() As clsColumnReference
  11. #End Region
  12.  
  13.  
  14. #Region "clsColumnReference()"
  15.     Class clsColumnReference
  16.         Public strColumnText As String
  17.         Public lngParentIndex As Long
  18.         Public blnIsMasterParent As Boolean
  19.         Public strChildSAPCodes As String
  20.     End Class
  21. #End Region
  22.  
  23.  
  24. #Region "doInitHeaders()"
  25.     Private Sub doInitHeaders()
  26.         If colMasterHeaders Is Nothing Then ReDim colMasterHeaders(0) : colMasterHeaders(0) = New clsColumnReference()
  27.         If colSecondHeaders Is Nothing Then ReDim colSecondHeaders(0) : colSecondHeaders(0) = New clsColumnReference()
  28.         If colThirdHeaders Is Nothing Then ReDim colThirdHeaders(0) : colThirdHeaders(0) = New clsColumnReference()
  29.     End Sub
  30. #End Region
  31.  
  32.  
  33. #Region "sqlAddHeaders()"
  34.     Public Sub sqlAddHeaders(ByVal strData As String, ByVal strChildSAPCode As String)
  35.         Dim i As Long, strHeaders() As String = Split(strData, "|"), lngParentIndex As Long
  36.         Dim blnFoundText As Boolean = False : doInitHeaders()
  37.  
  38.  
  39.         '' Master Headers
  40.         ''
  41.         For i = 0 To UBound(colMasterHeaders)
  42.             With colMasterHeaders(i)                
  43.                 If strHeaders(0) = .strColumnText Then
  44.                     blnFoundText = True
  45.                     Exit For
  46.                 End If
  47.             End With
  48.         Next
  49.         If Not blnFoundText Then
  50.             ReDim Preserve colMasterHeaders(UBound(colMasterHeaders) + 1)
  51.             colMasterHeaders(UBound(colMasterHeaders)) = New clsColumnReference()
  52.             With colMasterHeaders(UBound(colMasterHeaders))
  53.                 .blnIsMasterParent = True
  54.                 .lngParentIndex = -1
  55.                 .strColumnText = strHeaders(0)
  56.                 lngParentIndex = UBound(colMasterHeaders)                
  57.             End With
  58.         End If
  59.         blnFoundText = False
  60.  
  61.  
  62.         '' Secondary Headers
  63.         ''
  64.         For i = 0 To UBound(colSecondHeaders)
  65.             With colSecondHeaders(i)
  66.                 If strHeaders(1) = .strColumnText Then
  67.                     blnFoundText = True                    
  68.                     Exit For
  69.                 End If
  70.             End With
  71.         Next
  72.         If Not blnFoundText Then
  73.             ReDim Preserve colSecondHeaders(UBound(colSecondHeaders) + 1)
  74.             colSecondHeaders(UBound(colSecondHeaders)) = New clsColumnReference()
  75.             With colSecondHeaders(UBound(colSecondHeaders))
  76.                 .blnIsMasterParent = False
  77.                 .lngParentIndex = lngParentIndex
  78.                 .strColumnText = strHeaders(1)
  79.                 lngParentIndex = i                
  80.             End With
  81.         End If
  82.         blnFoundText = False
  83.  
  84.  
  85.         '' Third Headers
  86.         ''
  87.         For i = 0 To UBound(colThirdHeaders)
  88.             If strHeaders(2) = colThirdHeaders(i).strColumnText Then
  89.                 colThirdHeaders(i).strChildSAPCodes += strChildSAPCode
  90.                 blnFoundText = True
  91.                 Exit For
  92.             End If
  93.         Next
  94.         If Not blnFoundText Then
  95.             ReDim Preserve colThirdHeaders(UBound(colThirdHeaders) + 1)
  96.             colThirdHeaders(UBound(colThirdHeaders)) = New clsColumnReference()
  97.             With colThirdHeaders(UBound(colThirdHeaders))
  98.                 .blnIsMasterParent = False
  99.                 .lngParentIndex = lngParentIndex
  100.                 .strColumnText = strHeaders(2)                
  101.                 .strChildSAPCodes = strChildSAPCode
  102.             End With
  103.         End If
  104.  
  105.         Dim colThirdLevel As New clsColumnReference()
  106.         colThirdLevel = colThirdHeaders(UBound(colThirdHeaders))
  107.  
  108.         Dim colSecondLevel As New clsColumnReference()
  109.         colSecondLevel = colSecondHeaders(colThirdLevel.lngParentIndex)
  110.  
  111.         Dim colMasterLevel As New clsColumnReference()
  112.         colMasterLevel = colMasterHeaders(colSecondLevel.lngParentIndex)
  113.  
  114.         doLogFile(colMasterLevel.strColumnText & ":" & _
  115.                     colSecondLevel.strColumnText & ":" & _
  116.                     colThirdLevel.strColumnText & ":" & _
  117.                     colThirdLevel.strChildSAPCodes)
  118.  
  119.  
  120.     End Sub
  121.  
  122.     Private Sub doLogFile(ByVal strString As String)
  123.         Dim lngFileHandle As Long = FreeFile()
  124.         FileOpen(lngFileHandle, "c:\mylog.txt", OpenMode.Append)
  125.         Print(lngFileHandle, strString & vbCrLf)
  126.         FileClose(lngFileHandle)
  127.     End Sub
  128.  
  129. #End Region
  130. End Module