• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

Getchunk : argument not optional error

I am getting the error 'argument not optional' on line 'bytes() = rs(PFName).GetChunk(Block_Size)' with 'getchunk' highlighted as the error. I took this code from another site so i assume i've not defined something correctly but i don't know what ! Can anyone offer any suggestions ?

Public Sub FillPhoto(rs As Recordset, PFName As String, SizeField As String, Picture1 As PictureBox)
On Error GoTo Handler
Dim bytes() As Byte
Dim file_name As String
Dim file_num As Integer
Dim file_length As Long
Dim num_blocks As Long
Dim left_over As Long
Dim block_num As Long
Dim hgt As Single

    'me.imgPhoto.Visible = False
    Screen.MousePointer = vbHourglass

    ' Get a temporary file name.
    file_name = TemporaryFileName()

    ' Open the file.
    file_num = FreeFile
    Open file_name For Binary As #file_num

    ' Copy the data into the file.
    file_length = rs(SizeField)
    num_blocks = file_length / Block_Size
    left_over = file_length Mod Block_Size

    For block_num = 1 To num_blocks
        bytes() = rs(PFName).GetChunk(Block_Size)
        Put #file_num, , bytes()
    Next block_num

    If left_over > 0 Then
        bytes() = rs(PFName).GetChunk(left_over)
        Put #file_num, , bytes()
    End If

    Close #file_num

    Picture1.Picture = LoadPicture(file_name)
    Screen.MousePointer = vbDefault
Exit Sub

    Debug.Print Err.Description
    Resume Next
End Sub
1 Solution
How To Use GetChunk and AppendChunk Methods of RDO and ADO Object
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now