Afetr i need to loop trought the 2 items in collection Key and item
note:
see in the code the part where is "???".
Code: Select all
Option Explicit
Dim I As Long, D_KEY As String, D_ITEM As String
Dim MYDICT As Dictionary, CONTA As Long
Dim nFileNum As Integer, SText As String, sNextLine As String, lLineCount As Long, MText As String
Sub TEST_DICTIONARY()
Set MYDICT = New Dictionary
nFileNum = FreeFile
Open "C:\TEMP\TAB.TXT" For Input As nFileNum
lLineCount = 0
CONTA = 0
Do While Not EOF(nFileNum)
Line Input #nFileNum, sNextLine
If Mid(sNextLine, 1, 17) = "CODICE" Then
SText = Trim(Mid(sNextLine, 19, 4))
MText = Trim(Mid(sNextLine, 38, 50))
If MYDICT.Exists(SText) = False Then
MYDICT.Add SText, MText
CONTA = CONTA + 1
End If
End If
Loop
For I = 0 To MYDICT.Count - 1
D_KEY = "???" < SText
D_ITEM = "???" < MText
Next I
Close nFileNum
Set MYDICT = Nothing
End Sub