Try this: First, create a file (accttypes.txt) that looks like this:
Code:
T84,SP
T14,SW
T15,NOS
T16,SUN
Next, add a reference in your project to the Microsoft Scripting Runtime (scrrun.dll). Now create a function that reads the text file and populates a Dictionary:
Code:
Private Function LoadAccountTypes(ByVal FileName As String) As Scripting.Dictionary
Dim hFile As Integer
Dim sText As String
Dim Values() As String
Dim AccountTypes As Scripting.Dictionary
Set AccountTypes = New Scripting.Dictionary
hFile = FreeFile
Open FileName For Input As hFile
Do Until EOF(hFile)
Line Input #hFile, sText
If Len(sText) > 0 Then
Values = Split(sText, ",")
AccountTypes.Add Values(0), Values(1)
End If
Loop
Close hFile
Set LoadAccountTypes = AccountTypes
End Function
Finally, modify your code to use the Dictionary to convert acct_type to acct_prod:
Code:
Dim AccountTypes As Scripting.Dictionary
Set AccountTypes = LoadAccountTypes("d:\path\accttypes.txt")
Do While fnum(EOF) = False
Line Input cmne, acct_type
acct_prod = AccountTypes(acct_type)
Loop
Bookmarks