显示图片到picture的函数
fldpic失数据库中图片的字段
picshow是picture
你自己换一个image
Public Function ReadPic(ByVal fldPic As ADODB.Field, picShow As PictureBox) As Boolean
Dim strTemp As String
Dim strFree As String
Dim lngFldSize As Long
Dim bytFile() As Byte
Dim lngBlocks As Long
Dim lngLeft As Long
Dim lngNum As Long
On Error GoTo ErrHandler
strTemp = App.Path & "\temppic.tmp"
strFree = FreeFile
Open strTemp For Binary Access Write As strFree lngFldSize = fldPic.ActualSize
If lngFldSize = 0 Then Exit Function
lngBlocks = lngFldSize \ BLOCK_SIZE
lngLeft = lngFldSize Mod BLOCK_SIZE
For lngNum = 1 To lngBlocks
bytFile() = fldPic.GetChunk(BLOCK_SIZE)
Put strFree, , bytFile()
Next lngNum
If lngLeft > 0 Then
bytFile() = fldPic.GetChunk(lngLeft)
Put strFree, , bytFile()
End If
Close strFree
picShow.Picture = LoadPicture(strTemp)
ReadPic = True
Exit Function
ErrHandler:
MsgBox "ERR"
ReadPic = False
End Function
fldpic失数据库中图片的字段
picshow是picture
你自己换一个image
Public Function ReadPic(ByVal fldPic As ADODB.Field, picShow As PictureBox) As Boolean
Dim strTemp As String
Dim strFree As String
Dim lngFldSize As Long
Dim bytFile() As Byte
Dim lngBlocks As Long
Dim lngLeft As Long
Dim lngNum As Long
On Error GoTo ErrHandler
strTemp = App.Path & "\temppic.tmp"
strFree = FreeFile
Open strTemp For Binary Access Write As strFree lngFldSize = fldPic.ActualSize
If lngFldSize = 0 Then Exit Function
lngBlocks = lngFldSize \ BLOCK_SIZE
lngLeft = lngFldSize Mod BLOCK_SIZE
For lngNum = 1 To lngBlocks
bytFile() = fldPic.GetChunk(BLOCK_SIZE)
Put strFree, , bytFile()
Next lngNum
If lngLeft > 0 Then
bytFile() = fldPic.GetChunk(lngLeft)
Put strFree, , bytFile()
End If
Close strFree
picShow.Picture = LoadPicture(strTemp)
ReadPic = True
Exit Function
ErrHandler:
MsgBox "ERR"
ReadPic = False
End Function
显示
存储的方法都有
自己看看吧