CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Posts
    4

    Exclamation as Any Keyword in VB.NET?

    hi! there im new in programming in VB.NET. i want to translate my VB code into VB.NET(VS.NET 2003)..

    in my VB project i had this which it works perfectly

    - a module called chain.bas
    - a test.dll

    in my chain.bas i had this

    Code:
    Global Const ALGO_1 = 0
    Global Const ALGO_2 = 1
    Global Const ALGO_3 = 3
    Global Const DATA_A = 1
    Global Const DATA_B = 2
    
    Declare Function Chain_A Lib "test.dll" (ByRef Data As Any, ByRef key As Any, ByVal Single As Integer, ByVal Blocks As Long, ByVal method As Long) As Long
    Declare Function Chain_B Lib "test.dll" (ByRef arc As Any, ByRef Data As Any, ByRef key As Any, ByVal Blocks As Long) As Long
    Declare Function Chain_C Lib "test.dll" (ByRef arc As Any, ByRef Data As Any, ByRef key As Any, ByVal Blocks As Long) As Long

    i had this in commandbutton

    Code:
    Dim Data(1 To 8) As Byte
    Dim key(1 To 8) As Byte
    
    ' ** some codes **
    
    Call Chain_A(Data(1), key(1), ALGO_1, 1, DATA_A)
    but when it try to convert it in VB.NET

    - a class called chain.vb
    - a test.dll
    Code:
    public Class chain
    
        Public Const ALGO_1 = 0
        Public Const ALGO_2 = 1
        Public Const ALGO_3 = 3
        Public Const DATA_A = 1
        Public Const DATA_B = 2
    
    Declare Function Chain_A Lib "test.dll"  (ByRef Data As Object, ByRef key As Object, ByVal TripleDES As Short, ByVal Blocks As Integer, ByVal method As Integer) As Integer
    Declare Function Chain_B Lib "test.dll" (ByRef arc As Object, ByRef Data As Object, ByRef key As Object, ByVal Blocks As Integer) As Integer
    Declare Function Chain_C Lib "test.dll" (ByRef arc As Object, ByRef Data As Object, ByRef key As Object, ByVal Blocks As Integer) As Integer
    
    End Class
    in my commandbutton ive encuntered an error An unhandled exception of type 'System.DllNotFoundException' occurred in ChainDES.exe
    it says that Unable to load DLL (test.dll).

    Code:
    Dim Data(8) As Byte
    Dim key(8) As Byte
    
    ' ** some codes **
    
    Call chain.Chain_A(Data(1), key(1), chain.ALGO_1, 1, chain.DATA_A)

    kindly help regarding this matter.. im getting stuck in here.. i appreciate you guys fpr helping me..

  2. #2
    Join Date
    Sep 2002
    Location
    Mumbai
    Posts
    98

    Re: as Any Keyword in VB.NET?

    Try adding the dll to the reference of the project, from the solution explorer --> Reference --> Right Click --> Add Reference

  3. #3
    Join Date
    Jun 2005
    Posts
    4

    Re: as Any Keyword in VB.NET?

    an error appear
    'System.Runtime.InteropServices.InvalidOleVariantTypeException' occurred in Chain.exe Additional information: Specified OLE variant is invalid.

    when i breakpoint in this code

    Code:
    Call chain.Chain_A(Data(1), key(1), chain.ALGO_1, 1, chain.DATA_A)
    or with this declaration i used the Object since Any keyword is not available anymore in VB.Net

    Code:
    Declare Function Chain_A Lib "test.dll"  (ByRef Data As Object, ByRef key As Object, ByVal TripleDES As Short, ByVal Blocks As Integer, ByVal method As Integer) As Integer 
    Declare Function Chain_B Lib "test.dll" (ByRef arc As Object, ByRef Data As Object, ByRef key As Object, ByVal Blocks As Integer) As Integer 
    Declare Function Chain_C Lib "test.dll" (ByRef arc As Object, ByRef Data As Object, ByRef key As Object, ByVal Blocks As Integer) As Integer
    tnx for helping me..
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured