Results 1 to 14 of 14

Thread: Please help me change this vb module to vb.net code

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269

    Please help me change this vb module to vb.net code

    i have no idea how to work with the "Any's", and if i change it to "Object" in vb.net, it runs VERY slowly..
    Attached Files Attached Files

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    This is an extract from MSDN from a section titled "Preparing Your Visual Basic 6.0 Applications for the Upgrade to Visual Basic .NET".

    The second case is using the As Any variable type in a Declare statement. This is not supported in Visual Basic .NET. Variables of type As Any were often used to pass a variable that was either a string or Null; you can replace this Visual Basic 6.0 usage by declaring two forms of the API, one with longs, one with strings. For example, the GetPrivateProfileString API has a parameter lpKeyName of type As Any:

    Private Declare Function GetPrivateProfileString Lib "kernel32" Alias
    "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
    lpKeyName As Any, ByVal lpDefault As String, ByVal
    lpReturnedString As String, ByVal nSize As Long, ByVal
    lpFileName As String) As Long


    You can remove the “As Any” by replacing the Declare with two versions; one that accepts a long, and one that accepts a string:

    Private Declare Function GetPrivateProfileStringKey Lib "kernel32" Alias
    "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
    lpKeyName As String, ByVal lpDefault As String, ByVal
    lpReturnedString As String, ByVal nSize As Long, ByVal
    lpFileName As String) As Long

    Private Declare Function GetPrivateProfileStringNullKey Lib "kernel32"
    Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String,
    ByVal lpKeyName As Long, ByVal lpDefault As String, ByVal
    lpReturnedString As String, ByVal nSize As Long, ByVal
    lpFileName As String) As Long
    This world is not my home. I'm just passing through.

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB6 to VB.NET
    No user-defined data types , it's replaced with structures .
    As Any = can be As Object (it works usually).
    As Long = As Integer

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269
    im sorry, i dont know any api at all.. please can someone help me transform that code to vb.net code?

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    For the API declarations , follow the above instructions for VB to VB.NET translation issue .

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Download the tool , get the right declaration to adapt API calls in your VB.NET Proj .
    http://www.vbforums.com/showthread.p...hreadid=258460

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269
    but i cant even tell if a string is being passed or a long

  8. #8

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Change this :
    VB Code:
    1. Private Type INTERNET_CACHE_ENTRY_INFO
    2.    dwStructSize As Long
    3.    lpszSourceUrlName As Long
    4.    lpszLocalFileName As Long
    5.    CacheEntryType As Long
    6.    dwUseCount As Long
    7.    dwHitRate As Long
    8.    dwSizeLow As Long
    9.    dwSizeHigh As Long
    10.    lpHeaderInfo As Long
    11.    dwHeaderInfoSize As Long
    12.    lpszFileExtension As Long
    13.    dwExemptDelta As Long
    14. End Type


    To this :
    VB Code:
    1. Private Structure INTERNET_CACHE_ENTRY_INFO
    2.         Dim dwStructSize As Integer
    3.         Dim lpszSourceUrlName As Integer
    4.         Dim lpszLocalFileName As Integer
    5.         Dim CacheEntryType As Integer
    6.         Dim dwUseCount As Integer
    7.         Dim dwHitRate As Integer
    8.         Dim dwSizeLow As Integer
    9.         Dim dwSizeHigh As Integer
    10.         Dim lpHeaderInfo As Integer
    11.         Dim dwHeaderInfoSize As Integer
    12.         Dim lpszFileExtension As Integer
    13.         Dim dwExemptDelta As Integer
    14.     End Structure
    and see if it works . Again for the API declarations , change all Long types to Integer types .

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269
    still no luck

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This is the upgrade proj of your module in VB6 . Try it out .
    Attached Files Attached Files

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269
    thats just done via the upgrade option in vb.net

    it doesnt fix the any problem and it stlil doesnt work

  13. #13
    Lively Member neodatatype's Avatar
    Join Date
    Aug 2002
    Location
    Italy
    Posts
    103
    it doesnt fix the any problem and it stlil doesnt work
    I tryied the ApiViewer suggested but it crashes as it stats.

    I tryied it just to view as it will convert the VB6 Any keyword that in VB.NET is no longer supported.

    You have to Declare multiple and typized function.

    If the old Api Func was used to pass a string to the "Any" parameter you must change the As Any to As String.

    Bye
    > NeoDataType.net <

    Try my Free .Net Reporting Tool!

  14. #14
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Ok , I hate upgraded code , thought it often works (but I used that just because it's your last option) . Anyways , what do these APIs do in the end ?

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