S
stefan429
Guest
Hello everyone, my first post here and I'm quite new to coding in VB. I wanted to upgrade my VB6 project to VB.NET and getting the error in the title.
Here is the code in question:
Private Function GetAddress(ByRef FunAddr As Integer) As Integer
GetAddress = FunAddr
End Function
Private Sub InitMessages()
'UPGRADE_WARNING: Add a delegate for AddressOf HandlePlayerOnline Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="E9E157F7-EF0C-4016-87B7-7D7FBBC6EE08"'
HandleDataSub(ClientPackets.CPlayerOnline) = GetAddress(AddressOf HandlePlayerOnline)
...more of those HandleDataSub lines
End Sub
I tried adding this to the top (adapted from MSDN):
Delegate Function GetAddressProcDelegate(ByVal hwnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Declare Function SetWindowLong Lib "USER32.DLL" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal attr As Integer, ByVal lVal As GetAddressProcDelegate) As Integer
Sub GetAddressWindow(ByVal hwnd As Integer)
If PrevProcPtr = 0 Then
PrevProcPtr = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf GetAddressProc)
End If
End Sub
But I just keep getting errors, or messages that the PrevProcPtr is not declared. I'm at a loss.
Could someone help?
EDIT: And the sub HandlePlayerOnline
Private Sub HandlePlayerOnline(ByVal Index As Integer, ByRef Data() As Byte, ByVal StartAddr As Integer, ByVal ExtraVar As Integer)
'UPGRADE_WARNING: Arrays in structure buffer may need to be initialized before they can be used. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="814DF224-76BD-4BB4-BFFB-EA359CB9FC48"'
Dim buffer As typeBuffer
Dim Slot As Integer
Dim LoginN, CharN As String
Dim ServerN As Byte
Buffer_NewFromBytes(buffer, Data)
Buffer_ReadLong(buffer, Slot)
Buffer_ReadString(buffer, LoginN)
Buffer_ReadString(buffer, CharN)
Buffer_ReadByte(buffer, ServerN)
Buffer_Unload(buffer)
If Slot > 0 Then
PlayerOnline(Slot).LoginName = LoginN
PlayerOnline(Slot).CharName = CharN
PlayerOnline(Slot).ServerNum = ServerN
PlayerOnline(Slot).Slot = Index
VB6.SetItemString(frmMain.lstPlayerOn, Slot - 1, "Server: " & PlayerOnline(Slot).Slot & " | Account: " & PlayerOnline(Slot).LoginName)
SendPlayerOnlineToServer(Index, Slot, LoginN, CharN, ServerN)
End If
End Sub
Continue reading...
Here is the code in question:
Private Function GetAddress(ByRef FunAddr As Integer) As Integer
GetAddress = FunAddr
End Function
Private Sub InitMessages()
'UPGRADE_WARNING: Add a delegate for AddressOf HandlePlayerOnline Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="E9E157F7-EF0C-4016-87B7-7D7FBBC6EE08"'
HandleDataSub(ClientPackets.CPlayerOnline) = GetAddress(AddressOf HandlePlayerOnline)
...more of those HandleDataSub lines
End Sub
I tried adding this to the top (adapted from MSDN):
Delegate Function GetAddressProcDelegate(ByVal hwnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Declare Function SetWindowLong Lib "USER32.DLL" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal attr As Integer, ByVal lVal As GetAddressProcDelegate) As Integer
Sub GetAddressWindow(ByVal hwnd As Integer)
If PrevProcPtr = 0 Then
PrevProcPtr = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf GetAddressProc)
End If
End Sub
But I just keep getting errors, or messages that the PrevProcPtr is not declared. I'm at a loss.
Could someone help?
EDIT: And the sub HandlePlayerOnline
Private Sub HandlePlayerOnline(ByVal Index As Integer, ByRef Data() As Byte, ByVal StartAddr As Integer, ByVal ExtraVar As Integer)
'UPGRADE_WARNING: Arrays in structure buffer may need to be initialized before they can be used. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="814DF224-76BD-4BB4-BFFB-EA359CB9FC48"'
Dim buffer As typeBuffer
Dim Slot As Integer
Dim LoginN, CharN As String
Dim ServerN As Byte
Buffer_NewFromBytes(buffer, Data)
Buffer_ReadLong(buffer, Slot)
Buffer_ReadString(buffer, LoginN)
Buffer_ReadString(buffer, CharN)
Buffer_ReadByte(buffer, ServerN)
Buffer_Unload(buffer)
If Slot > 0 Then
PlayerOnline(Slot).LoginName = LoginN
PlayerOnline(Slot).CharName = CharN
PlayerOnline(Slot).ServerNum = ServerN
PlayerOnline(Slot).Slot = Index
VB6.SetItemString(frmMain.lstPlayerOn, Slot - 1, "Server: " & PlayerOnline(Slot).Slot & " | Account: " & PlayerOnline(Slot).LoginName)
SendPlayerOnlineToServer(Index, Slot, LoginN, CharN, ServerN)
End If
End Sub
Continue reading...