Private Sub lstPeople_Click()
Dim rs As ADODB.Recordset
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 picPerson.Visible = False
Screen.MousePointer = vbHourglass
DoEvents 注释: Get the record.
Set rs = m_DBConn.Execute("SELECT * FROM People WHERE Name=注释:" & _
lstPeople.Text & "注释:", , adCmdText)
If rs.EOF Then Exit Sub 注释: 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!FileLength
num_blocks = file_length / BLOCK_SIZE
left_over = file_length Mod BLOCK_SIZE For block_num = 1 To num_blocks
bytes() = rs!Picture.GetChunk(BLOCK_SIZE)
Put #file_num, , bytes()
Next block_num If left_over > 0 Then
bytes() = rs!Picture.GetChunk(left_over)
Put #file_num, , bytes()
End If Close #file_num 注释: Display the picture file.
picPerson.Picture = LoadPicture(file_name)
picPerson.Visible = True Width = picPerson.Left + picPerson.Width + Width - ScaleWidth
hgt = picPerson.Top + picPerson.Height + Height - ScaleHeight
If hgt < 1440 Then hgt = 1440
Height = hgt Kill file_name
Screen.MousePointer = vbDefault
End Sub 具体参照
http://www.21code.com/school/?pos=view&id=384
Dim rs As ADODB.Recordset
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 picPerson.Visible = False
Screen.MousePointer = vbHourglass
DoEvents 注释: Get the record.
Set rs = m_DBConn.Execute("SELECT * FROM People WHERE Name=注释:" & _
lstPeople.Text & "注释:", , adCmdText)
If rs.EOF Then Exit Sub 注释: 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!FileLength
num_blocks = file_length / BLOCK_SIZE
left_over = file_length Mod BLOCK_SIZE For block_num = 1 To num_blocks
bytes() = rs!Picture.GetChunk(BLOCK_SIZE)
Put #file_num, , bytes()
Next block_num If left_over > 0 Then
bytes() = rs!Picture.GetChunk(left_over)
Put #file_num, , bytes()
End If Close #file_num 注释: Display the picture file.
picPerson.Picture = LoadPicture(file_name)
picPerson.Visible = True Width = picPerson.Left + picPerson.Width + Width - ScaleWidth
hgt = picPerson.Top + picPerson.Height + Height - ScaleHeight
If hgt < 1440 Then hgt = 1440
Height = hgt Kill file_name
Screen.MousePointer = vbDefault
End Sub 具体参照
http://www.21code.com/school/?pos=view&id=384
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货