|
-
Jan 8th, 2007, 07:57 PM
#1
Thread Starter
New Member
Convert While in C# to VB.Net
I am a little stuck, I am following these examples and trying to do them in VB.Net but have run into a problem.
SharpPcap Examples
I am working on example 4 and am not sure how I would convert this to VB.Net
while( (packet=device.PcapGetNextPacket()) != null )
I have tried:
While Not (Packet = Device.PcapGetNextPacket) Is Nothing
With no go.
How would I convert this C# statement to VB.Net?
Thanks,
David
-
Jan 8th, 2007, 08:18 PM
#2
Lively Member
Re: Convert While in C# to VB.Net
i think this will work
While Not ((packet = device.PcapGetNextPacket) Is Nothing)
-
Jan 8th, 2007, 08:26 PM
#3
Re: Convert While in C# to VB.Net
In C# an assignment, i.e. using "=" to assign a value to a variable, returns a value, specifically the value that was assigned to the variable. In VB that is not the case, so you cannot perform an assignment and compare the assigned value in one line. In VB you'd have to do something like this:
VB Code:
packet = device.PcapGetNextPacket()
While packet IsNot Nothing
'Do something.
packet = device.PcapGetNextPacket()
End While
Note that IsNot is new in VB 2005. ALWAYS specify your version. In previous versions you have to use Not ... Is.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|