Why function returns 0?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Swan
    New Member
    • Mar 2008
    • 27

    Why function returns 0?

    I am creating OCX for Http Upload control.can anyone plz tell me why the function UploadFileHTTP returns 0 when used?I am posting my code----
    [CODE=vb]
    Public Function UploadFileHTTP( ByVal localFileName As String, ByVal remoteFileName As String) As Integer
    Dim nRet As Integer
    Dim bRet, bQueryInfo As Boolean
    Dim iRet As Integer
    Dim nFileHandle, i As Integer
    Dim bData(BUFFER_SI ZE - 1) As Byte
    Dim leftoversize As Long
    Dim blnSendRequest As Boolean
    Dim szContent As String

    nFileHandle = FreeFile

    hRequest = HttpOpenRequest (hConnect, "POST", "192.168.3. 13/Fileupload/Upload_Signatur e.asp", "HTTP/1.0", 0, 0, INTERNET_FLAG_N O_CACHE_WRITE, 0)
    If hRequest = 0 Then
    LastDllErrorInf o 'Call before calling any other dll function
    If Not HttpErrorCode = 0 Then
    Err.Raise HttpErrorCode, , HttpErrorString
    End If
    Exit Function
    End If

    blnSendRequest = HttpSendRequest (hRequest, vbNullString, 0, localFileName, Len(localFileNa me))
    bQueryInfo = HttpQueryInfo(h Request, HTTP_QUERY_CONT ENT_TYPE, remoteFileName, Len(remoteFileN ame), 0)

    Close nFileHandle
    InternetCloseHa ndle hRequest
    End Function[/CODE]
    Last edited by debasisdas; Apr 3 '08, 12:50 PM. Reason: added code=vb tags
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    You're not telling the fuction to return anything.

    UploadFileHTTP= bQueryInfo would make the function return the true/false value of HttpQueryInfo(* )

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Since you are returning anything from the function and the function return type is integer it returns 0.

      Comment

      Working...