There is a code written by another programmer which I want to improve. The purpose of the module is to get a live image stream from camera and to display it in the picture window. It is doing it over the TCP IP connection. Here is how it is done Get the
Private Sub DataArrival(ByVal bytes As Long)
Dim str As String
' check the socket for data
camera.GetData str
Dim str As String
While InStr(str, Terminator) <> 0
**Do some processing and put only the data in the variable str
str = Mid(str, index, 1000)
lImgSize = lImgSize + Len(str)
strImg = strImg + str
If lImageSize >= 1614414 Then
Dim fileno As Integer
fileno = FreeFile()
Open ".\Imagefile.txt" For Output As #intFileNo
Print #fileno , strImg
Close #fileno
End If
End Sub
I have an input image stream coming and converting it to string and I am calculating the size to check the end of the image to write it in to a file. But the hardcoded value does not guarantee the end of file always. Sometimes If the image size is little less than the size, my picture box is not update with a live image.
EDIT: This is what the image.txt file contains.
1
1575020 // file size header
424D36040C0000000000360400002800000000040000000300000100080000000000000000000000
--data--
--data--
020303030203010302010202030002030203020302020302030202030102
3BFB
Is there any other efficient way to handle this in VB6?