c0zee Level: Guest

|
Can somebody help me convert this VB.NET code to VB6
hi all!
i found this piece of code that helps to strip extra header information when accessing an image file from SQL Server. The problem is im only using VB 6 and i need help to convert this code to VB6.
Anyone there that can help me?
Thanks in advance!
This is the code :
Private Sub LoadEmployeePhoto( _
ByVal employeeID As Integer)
Dim da As SqlDataAdapter
Dim dt As New DataTable()
BreakIfChecked(chkDebug)
Try
Dim strCnn As String = Constants.SQLConnectionString
Dim strSQL As String = _
Constants.SQLPhoto & _
" WHERE EmployeeID = " & employeeID.ToString
Dim msPic As MemoryStream
Dim abytPic() As Byte
' Signature bytes of an
' OLE container header.
Const OLEbyte0 As Byte = 21
Const OLEbyte1 As Byte = 28
' Number of bytes in OLE container header.
Const OLEheaderLength As Integer = 78
da = New SqlDataAdapter(strSQL, strCnn)
da.Fill(dt)
If dt.Rows.Count > 0 Then
' Move binary picture data into the byte array.
abytPic = CType(dt.Rows(0)("Photo"), Byte())
' Test for an OLE container header.
If (abytPic(0) = OLEbyte0) And _
(abytPic(1) = OLEbyte1) Then
' Use a second array to strip off the header.
' Make it big enough to hold the bytes after
' the header.
Dim abytStripped( _
abytPic.Length - OLEheaderLength - 1) As Byte
' Strip off the header by copying the bytes
' after the header.
System.Buffer.BlockCopy( _
src:=abytPic, srcOffset:=OLEheaderLength, _
dst:=abytStripped, dstOffset:=0, _
count:=abytPic.Length - OLEheaderLength)
' Load the new byte array into a MemoryStream.
msPic = New MemoryStream(abytStripped)
Else
' Load the original byte array into a MemoryStream.
msPic = New MemoryStream(abytPic)
End If
' Set the picture box image, using the stream.
picEmployee.Image = Image.FromStream(msPic)
End If
Catch exp As Exception
MessageBox.Show(exp.Message)
End Try
End Sub
|