Question : 'AddressOf' expression cannot be converted to 'Integer' because 'Integer' is not a delegate type.

I ahve the following error in code that has been upgraded from VB6 to VB.net


'AddressOf' expression cannot be converted to 'Integer' because 'Integer' is not a delegate type.

The code is attatched - can anybody help?
1:
UZUSER.UZDLLPrnt = FnPtr(AddressOf UZDLLPrnt)

Answer : 'AddressOf' expression cannot be converted to 'Integer' because 'Integer' is not a delegate type.

Hello, ict-torquilclark,

Your function FnPtr does not appear to do anything.  So for starters, I would eliminate it.  

Then you could try adding delegate specifications for your functions.  I've shown a sample modification of your code in the attached snippet.

Then just use:

        UZUSER.UZDLLPrnt = AddressOf UZDLLPrnt

for your assignment.

Similar changes would also need to be made for the other functions.

I'm not sure if Wiz_SingleEntryUnzip will handle this correctly, though.  But it could be worth a try.

Cheers,
Randy
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
    '-- UNZIP32.DLL Userfunctions Structure
    Delegate Function UZDLLPrntPtr(ByRef fname As UNZIPCBChar, ByVal X As Integer) As Integer
    Private Structure USERFUNCTION
        'Dim UZDLLPrnt As Integer ' Pointer To Apps Print Function
        Dim UZDLLPrnt As UZDLLPrntPtr ' Pointer To Apps Print Function
        Dim UZDLLSND As Integer ' Pointer To Apps Sound Function
        Dim UZDLLREPLACE As Integer ' Pointer To Apps Replace Function
        Dim UZDLLPASSWORD As Integer ' Pointer To Apps Password Function
        Dim UZDLLMESSAGE As Integer ' Pointer To Apps Message Function
        Dim UZDLLSERVICE As Integer ' Pointer To Apps Service Function (Not Coded!)
        Dim TotalSizeComp As Integer ' Total Size Of Zip Archive
        Dim TotalSize As Integer ' Total Size Of All Files In Archive
        Dim CompFactor As Integer ' Compression Factor
        Dim NumMembers As Integer ' Total Number Of All Files In The Archive
        Dim cchComment As Short ' Flag If Archive Has A Comment!
    End Structure
Random Solutions  
 
programming4us programming4us