-
Dec 16th, 2008, 05:42 PM
#1
Thread Starter
Member
Speeding up this code.
Code:
Private Sub AuthData_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next 'If we run into an error continue
Dim Lens As Long, tmpLng As Long, AData As String 'Declare stuff
Lens = bytesTotal 'Grab how many bytes there are
Do While Lens >= 6 'Do the following as long as the len is over 6 bytes.
AuthData.PeekData AData$, vbString, Lens 'Get the data without removing it from the buffer
tmpLng = GetWord(Mid$(AData$, 5, 2)) + 6 'Get length of packet
If Lens >= tmpLng Then 'If the whole packet is in the data
AuthData.GetData AData$, vbString, tmpLng 'Get the data and remove packet from buffer
Call Parse(AData$) 'Process the packet
Lens = Lens - tmpLng
Else
Exit Sub
End If
Loop
End Sub
Is there anyway to speed this code up or make it faster? Also how else can I make VB code more faster, and less memory intesnse?
Last edited by gthkane; Dec 16th, 2008 at 05:49 PM.
-
Dec 16th, 2008, 06:11 PM
#2
Re: Speeding up this code.
This is quite seems like the fastest code. The things, that is may causing any slow down are in your own methods, just like Parse(), GetWord().
-
Dec 16th, 2008, 07:59 PM
#3
Re: Speeding up this code.
This won't help your speed, but you're using 'On Error Resume Next' without 'closing' it.
That can cause you problems.
For instance, if a error happens in your Parse procedure, the code will jump to back to the calling sub, or even somewhere else.
That can can give some odd errors and tricky debugging.
You want to make sure to use 'On Error Goto 0' to 'close' the error avoidance.
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
|