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..
Printable View
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..
This is an extract from MSDN from a section titled "Preparing Your Visual Basic 6.0 Applications for the Upgrade to Visual Basic .NET".
Quote:
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
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
im sorry, i dont know any api at all.. please can someone help me transform that code to vb.net code?
For the API declarations , follow the above instructions for VB to VB.NET translation issue .
Download the tool , get the right declaration to adapt API calls in your VB.NET Proj .
http://www.vbforums.com/showthread.p...hreadid=258460
but i cant even tell if a string is being passed or a long
Change this :
VB Code:
Private Type INTERNET_CACHE_ENTRY_INFO dwStructSize As Long lpszSourceUrlName As Long lpszLocalFileName As Long CacheEntryType As Long dwUseCount As Long dwHitRate As Long dwSizeLow As Long dwSizeHigh As Long lpHeaderInfo As Long dwHeaderInfoSize As Long lpszFileExtension As Long dwExemptDelta As Long End Type
To this :
and see if it works . Again for the API declarations , change all Long types to Integer types .VB Code:
Private Structure INTERNET_CACHE_ENTRY_INFO Dim dwStructSize As Integer Dim lpszSourceUrlName As Integer Dim lpszLocalFileName As Integer Dim CacheEntryType As Integer Dim dwUseCount As Integer Dim dwHitRate As Integer Dim dwSizeLow As Integer Dim dwSizeHigh As Integer Dim lpHeaderInfo As Integer Dim dwHeaderInfoSize As Integer Dim lpszFileExtension As Integer Dim dwExemptDelta As Integer End Structure
still no luck :(
This is the upgrade proj of your module in VB6 . Try it out .
thats just done via the upgrade option in vb.net
it doesnt fix the any problem :( and it stlil doesnt work
I tryied the ApiViewer suggested but it crashes as it stats.Quote:
it doesnt fix the any problem :( and it stlil doesnt work
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
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 ?