Re: Loop Problem (At Least I think)
From: McKirahan (News_at_McKirahan.com)
Date: 03/22/04
- Next message: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Previous message: hsjqueiroz: "Looking for wrong Gateway"
- In reply to: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Next in thread: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Reply: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Reply: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 22 Mar 2004 19:02:21 GMT
"Chris Guimbellot" <cguimbellot@FORGETSPAM.hifranchise.com> wrote in message
news:eByIewDEEHA.1604@TK2MSFTNGP11.phx.gbl...
> Thanks for the help. I used the code you gave me and have it working. I do
> have a few questions though:
>
> 1. If there are no images (items in the dictionary) matching the product
> code, then instead or showing zero between the parenthesis, it shows
> nothing. Everything else about the output seems to be correct.
Try this code to always return a number
Dim intPRD
Do While Not rstProp.EOF
propCode = rstProp("HIPropCode")
intPRD = 0
If objDIC.Exist(propCode) intPRD = objDIC.Item(propCode)
WScript.Echo propCode & " (" & intPRD & ")"
rstProp.MoveNext
Loop
> 2. I tried to examine the code you gave me. I understand everything except
> for the middle section you gave me including the "Do While...Loop" and the
> "If...End If" statement right below it. Specifically, I guess what I am
not
> understanding is why the iCount variable isn't set until after the first
> objDIC.Add line. It would seem to me that to add the item, you would have
to
> set iCount equal to something before you do. In regards to the "If strPRD
<>
> "" Then" statement (the one below the loop, outside of it), is this just
> there to add the last element to the dictionary? I am kind of messed up
when
> looking at this code. I could really use some help interpreting it.
Here is the code with comments:
'* read the file until the end
Do While Not ts.AtEndOfStream
'* assign the record to a variable
lineText = ts.ReadLine
'* has the first five bytes (Product Code) changed?
If strPRD <> Left(lineText,5) Then
'* is the "saved" Product Code non-blank
'* (i.e. not the first time)?
If strPRD <> "" Then
'* create a dictionary entry for the "saved" Product Code and
its Counter
objDIC.Add strPRD, iCount
End If
'* initialize the Counter
iCount = 0
'* "save" the Product Code
strPRD = Left(lineText,5)
End If
'* increment the Counter
iCount = iCount + 1
Loop
'* is the "saved" Product Code non-blank
'* (i.e. was there at least one record)?
If strPRD <> "" Then
'* create a dictionary entry for the "saved" Product Code and its
Counter
objDIC.Add strPRD, iCount
End If
> Once again, thanks for your help. I really appreciate it.
>
> Chris
[snip]
Does that help?
- Next message: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Previous message: hsjqueiroz: "Looking for wrong Gateway"
- In reply to: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Next in thread: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Reply: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Reply: Chris Guimbellot: "Re: Loop Problem (At Least I think)"
- Messages sorted by: [ date ] [ thread ]