Я столкнулся с ошибкой при обновлении кода VB6 до VB.NET.Ошибка возникает в AddressOf WindowProc
Невозможно преобразовать выражение AddressOf в «Integer», поскольку «Integer» не является типом делегата
Myобъявление для SetWindowLong
:
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"(
ByVal hWnd As Integer,
ByVal nIndex As Integer,
ByVal dwNewLong As Integer) As Integer
переменные:
Dim GWL_WNDPROC As Short = -4
Dim hWnd As Integer
Код для WindowProc
:
Function WindowProc(ByVal hw As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim x As Integer
Dim a As String
Dim wp As Short
Dim temp As Object
Dim ReadBuffer(1000) As Byte
'Debug.Print uMsg, wParam, lParam
Select Case uMsg
Case 1025
Debug.Print(VB6.TabLayout(uMsg, wParam, lParam))
Debug.Print(uMsg & " " & wParam & " " & lParam)
e_err = WSAGetAsyncError(lParam)
e_errstr = GetWSAErrorString(e_err)
If e_err <> 0 Then
Debug.Print("Error String returned -> " & e_err & " - " & e_errstr)
Debug.Print("Terminating....")
do_cancel = True
'Exit Function
End If
Select Case lParam
Case FD_READ 'lets check for data
x = recv(mysock, ReadBuffer(0), 1000, 0) 'try to get some
If x > 0 Then 'was there any?
'UPGRADE_ISSUE: Constant vbUnicode was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="55B59875-9A95-4B71-9D6A-7C294BF7139D"'
'default
'a = StrConv(System.Text.UnicodeEncoding.Unicode.GetString(ReadBuffer), vbUnicode) 'yep, lets change it to stuff we can understand
a = System.Text.UnicodeEncoding.Unicode.GetString(ReadBuffer) 'yep, lets change it to stuff we can understand
Debug.Print(a)
rtncode = Val(Mid(a, 1, 3))
'Debug.Print "Analysing code " & rtncode & "..."
Select Case rtncode
Case 354, 250
Progress = Progress + 1
Debug.Print(">>Progress becomes " & Progress)
Case 220
Debug.Print("Recieved Greenlight")
Green_Light = True
Case 221
Progress = Progress + 1
Debug.Print(">>Progress becomes " & Progress)
Case 550, 551, 552, 553, 554, 451, 452, 500
Debug.Print("There was some error at the server side")
Debug.Print("error code is " & rtncode)
do_cancel = True
End Select
End If
Case FD_CONNECT 'did we connect?
mysock = wParam 'yep, we did! yayay
'Debug.Print WSAGetAsyncError(lParam) & "error code"
'Debug.Print mysock & " - Mysocket Value"
Case FD_CLOSE 'uh oh. they closed the connection
Call closesocket(wp) 'so we need to close
End Select
End Select
'let the msg get through to the form
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Function
В чем причина ошибки Iполучить?Как мне решить проблему?