|
-
Jan 7th, 2011, 08:07 AM
#1
Thread Starter
New Member
[RESOLVED] Can't pass byte array as parameter in VB6
This might be a super basic issue, but I am a super basic programmer, so here I go.
I am creating a byte array with image information extacted from a database field (with a routine RhinoBull posted here some time ago)
These are the steps:
1. Create Recordset with all records in table which contain an image in the IMAGE field
2. Loop through the Recordset, and extract data in the IMAGE field to a byte() variable
3. With that info (per record) call a procedure that will use that byte() variable
Code:
Public Sub ExtractImage()
Dim bytes() As Byte
Dim file_length As Long
Dim num_blocks As Long
Dim left_over As Long
Dim block_num As Long
Dim hgt As Single
Dim Opr As New TablasManager
Dim Str_SQl As String
Dim Str_Cn_Prod As String
Str_Cn_Prod = "driver={SQL Server};server=200.9.220.58;database=SIG;uid=sa;pwd="
Str_SQl = "EXEC SIG.dbo.BT_L_Choferes"
On Error GoTo ErrHandler
Screen.MousePointer = vbHourglass
Set rs = Opr.EjecutarSPconRS(Str_SQl, adOpenForwardOnly, adLockReadOnly)
If rs.EOF Then
Screen.MousePointer = vbDefault
Exit Sub
End If
If IsNull(rs.Fields("BioID")) Then
Screen.MousePointer = vbDefault
Exit Sub
End If
rs.MoveFirst
Do While Not rs.EOF
file_length = rs.Fields("Filesize")
num_blocks = file_length / BLOCK_SIZE
left_over = file_length Mod BLOCK_SIZE
'get all chunks and write then to a temp file
For block_num = 1 To num_blocks
bytes() = rs.Fields("BioID").GetChunk(BLOCK_SIZE)
'Put #file_num, , bytes()
Next block_num
If left_over > 0 Then
bytes() = rs.Fields("BioID").GetChunk(left_over)
'Put #file_num, , bytes()
End If
cmdEnrollFinger2 (bytes())
Loop
Screen.MousePointer = vbDefault
Exit Sub
ErrHandler:
Debug.Print Err.Description
Err.Clear
Screen.MousePointer = vbDefault
'Resume Next
Exit Sub
End Sub
Private Sub cmdEnrollFinger2(ByRef huella() As Byte)
Dim iStatus As Long
Dim iEnSize As Long
Dim r_value, r_value2 As Boolean
r_value2 = bAPI4_HMFVEnroll(SENSOR_RESOLUTION, SENSOR_WIDTH, SENSOR_HEIGHT, huella(0), pEnrolledFeatures(0), iEnSize, iStatus)
End Sub
When I call cmdEnrollFinger2 (bytes()) from the first procedure I get an error (in spanish) that says something like "Compile error: Type mismatch error: an array or a user defined type was expected"
I kind of remember that passing byte arrays as parameters was a bit tricky, but I can't find any specific information on the web
Anyone can help??
Thanks
-
Jan 7th, 2011, 08:23 AM
#2
Re: Can't pass byte array as parameter in VB6
To start with you should not put brackets outside the parameters, because you are not using the Call keyword (or returning the value of a function). It should be like this:
Code:
cmdEnrollFinger2 bytes()
That is likely to solve the issue, but if not try also removing the remaining brackets.
-
Jan 7th, 2011, 10:02 AM
#3
Thread Starter
New Member
Re: Can't pass byte array as parameter in VB6
Thanks! That solved it...
-
Jan 7th, 2011, 10:18 AM
#4
Re: Can't pass byte array as parameter in VB6
Good stuff. 
To explain a little, you can put brackets around any value you like (eg: a = 1 + 2 can be re-written as a = (1) + (2) ), which is effectively what you had... but when you do that VB automatically changes the data type sometimes, and that can cause problems.
As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?
(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)
You can do it by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved". (like various other features of this site, you need JavaScript enabled in your browser for this to work).
Tags for this Thread
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
|