Home > Archive > Visual Basic > January 2006 > Let acts like Set
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| I have a project that processes messages, each message has a unique
identifier.
The application makes use of a string variable to hold the identifier
of the previous message and compare it to the identifier of the new
message. (works most of the time)
On some occasions we see a behavior that acts like the string have been
SET together.
Example:
Private sLastID as string
Private Sub ProcessMsg(sMsg as string)
Dim sThisID as string
sThisID = GetMsgID(sMsg)
If sThisID = sLastID then 'We have a duplicate ...
'Discard Message
Else
'Process the Message
'
'Do some Stuff ...
'Save this ID to compare next time ...
sLastID = sThisID
DoEvents
End If
End Sub
After the first duplicate is found, the routine discards several more,
but there not dups.
Any help is appreciated.
| |
| Randy Birch 2006-01-09, 7:16 pm |
| What happens if the doevents calls are commented out? And let and set are
not similar; set only works on objects.
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
Please reply to the newsgroups so all can participate.
"sid" <sidwelle@alexian.net> wrote in message
news:1135825319.227203.49750@g49g2000cwa.googlegroups.com...
:I have a project that processes messages, each message has a unique
: identifier.
:
: The application makes use of a string variable to hold the identifier
: of the previous message and compare it to the identifier of the new
: message. (works most of the time)
:
: On some occasions we see a behavior that acts like the string have been
: SET together.
:
: Example:
:
: Private sLastID as string
:
: Private Sub ProcessMsg(sMsg as string)
: Dim sThisID as string
:
: sThisID = GetMsgID(sMsg)
:
: If sThisID = sLastID then 'We have a duplicate ...
: 'Discard Message
: Else
: 'Process the Message
: '
: 'Do some Stuff ...
:
: 'Save this ID to compare next time ...
: sLastID = sThisID
: DoEvents
: End If
: End Sub
:
: After the first duplicate is found, the routine discards several more,
: but there not dups.
:
: Any help is appreciated.
:
| |
| Michael Cole 2006-01-09, 7:16 pm |
| sid wrote:
> I have a project that processes messages, each message has a unique
> identifier.
>
> The application makes use of a string variable to hold the identifier
> of the previous message and compare it to the identifier of the new
> message. (works most of the time)
>
> On some occasions we see a behavior that acts like the string have
> been SET together.
>
> Example:
>
> Private sLastID as string
>
> Private Sub ProcessMsg(sMsg as string)
> Dim sThisID as string
Just as another interesting thing you can try, try defining sLastID as a
Static inside the sub: -
Static sLastID as string
May not change anything, but you may just be fiddling with the value outside
the sub. And besides, its good coding practice to keep the variables
restricted in scope...
--
Regards,
Michael Cole
| |
|
| Thanks to everyone who replied.
After hours of reviewing logs, I found the problem, it was not related
to this loop.
Thanks.
Michael Cole wrote:
> sid wrote:
>
> Just as another interesting thing you can try, try defining sLastID as a
> Static inside the sub: -
>
> Static sLastID as string
>
> May not change anything, but you may just be fiddling with the value outside
> the sub. And besides, its good coding practice to keep the variables
> restricted in scope...
>
>
> --
> Regards,
>
> Michael Cole
|
|
|
|
|