Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all,
***YOU MIGHT HAVE TO TAKE MY TEXT AND CONVERT IT TO COURIER NEW BEFORE VIEWING***
I have a text file with a chunk of text as follows:
Del W Day Div Route Del Seq List-1 List-2 List-3
=== === === === ===== ======= ====== ====== ======
1 A 4 1 427 43.000 3 0 0
1 C 4 1 427 43.000 3 1 0
The below code tells me how offen the customer gets serviced (Freq).
If Instr(MyString, "=== === === === ===== ======= ====== ====== ======") > 0 Then
Line Input #Infile, Mystring
Freq = Trim$(Mid$(Mystring, 20, 5))
Line Input #Infile, MyString
Freq = Freq & Trim$(Mid$(Mystring, 20, 5))
If Freq = "A" or Freq = "B" or Freq = "C" or Freq = "D" Then
Freq = "E4W" 'every 4 weeks
ElseIf Freq = "AC" or Freq = "BD" Then
Freq = "E2W" 'every 2 weeks
ElseIf Freq = "AB" Then
Freq = "EW" 'every week
ElseIf Freq = "AA" Then
Freq = "EWx2" 'twice a week
End If
End If
It works great! The above customer gets serviced "E2W" or every two weeks. Now I want it to do a bit more. The section that has "List-1 List-2 List-3" represents product lists. I want to know the "Freq" of a particular product list. For example, above List-1 shows that product list 3 or "ProdList" is done in both week "A" and "C", therefore product list 3 equals "E2W". However, product list 1 is only in week "C", so it equals "E4W". Can someone help me figure out how to code this?
Thanks in advance.
Mike

Dim an array initially which will be filled with Product List numbers, and frequencies (2 dimensions)
As you read through the file, lookup the array to see if the Product List number is in there.
If it isn't in there, add a new element to the array - there will be one array element per product list, each element with two dimensions (product list number, and frequency)
Then, find the frequency code in the same way you are already doing.
Retrieve the product list array element from the array matching your product list number.
Check what the current frequency is - if there isn't one, then simply move in the calculated frequency.
If there is one, then use program logic to adjust what is in there already with the new frequency information.
At the end of the loop, you should have an array - taking your example two lines :
aProdList[1,1] = 3
aProdList[1,2] = "E2W"
aProdList[2,1] = 1
aProdList[2,2] = "E4W"This can also be presented as :
aProdList[1] = [3,"E2W"]
aProdList[2] = [1,"E4W"]The code will first encounter Product List 3 with it's A frequency, so a new array element will be added as follows :
ElementNumber = ElementNumber + 1
aProdList[ElementNumber,1] = 3
aProdList[ElementNumber,2] = "E4W"Then, the code will read the second line.
It will again encounter Product List 3 - and find an array element already present for Product List 3 - which already has "E4W" in the second element.
It will therefore change this to "E2W".
The code will also encounter Product List 1 - and not find an array element already for it, so will add one :
ElementNumber = ElementNumber + 1
aProdList[ElementNumber,1] = 3
aProdList[ElementNumber,2] = "E4W"I hope this makes sense - feel free to drop me an e-mail if not.

Thanks! I'll try this out first thing on Monday. If I run into a snag I will contact you via E-mail.

![]() |
![]() |
![]() |

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