函数
下面是函数
Public Function SavePictureToDB(Img_RS As ADODB.Recordset, sFileName As String)
Dim oPict As StdPicture
On Error GoTo procNoPicture
Set oPict = LoadPicture(sFileName)
'Exit Function if this is NOT a picture file
If oPict Is Nothing Then
MsgBox "Invalid Picture File! ", vbOKOnly, "Oops! "
SavePictureToDB = False
GoTo procExitSub
End If
If Img_RS.EOF Then
Img_RS.AddNew
End If
Set strStream = New ADODB.Stream
strStream.Type = adTypeBinary
strStream.Open
strStream.LoadFromFile sFileName
Img_RS.Fields( "IMG_PHOTO ").Value = strStream.Read
Img_RS.Fields( "SABUN ").Value = Txtsabun
Img_RS.Update
Image6.Picture = LoadPicture(sFileName)
SavePictureToDB = True
procExitSub:
Exit Function
procNoPicture:
MsgBox Error, vbInformation
SavePictureToDB = False
GoTo procExitSub
Resume Next
End Function
然后在 后面的一个里引用了这个函数
If Not SavePictureToDB(Img_Rst, .FileName) Then
想问一下,如何判断这个函数是boolean的函数,
如何知道他的返回值是什么类型的?(代码是别人写的)
高手指点
[解决办法]
这个函数的返回值没有明确定义,所以是variant
在函数里面返回的时候赋值是boolean而已。
如果需要明确返回类型可以改为
Public Function SavePictureToDB(Img_RS As ADODB.Recordset, sFileName As String) as boolean