PC Review


Reply
Thread Tools Rate Thread

Declare Function and "As Any"

 
 
Lance Geeck
Guest
Posts: n/a
 
      6th Apr 2004
I have many items that I lifted off from Microsoft's website several years
ago. These samples were in VB6.

I now want to convert an application to VB.NET. I am getting an error
that says "As Any is not supported in a declare statement" during the
automated
Conversion process.

Some examples of this are:
Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory"(ByRef
Destination As Any, ByRef Source As Any, ByVal Length As Integer)
Declare Function HTMLHelp Lib "hhctrl.ocx" Alias "HtmlHelpA"(ByVal
hwndCaller As Integer, ByVal pszFile As String, ByVal uCommand As Integer,
ByRef dwData As Any) As Integer

Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias
"RegSetValueExA"(ByVal hKey As Integer, ByVal lpValueName As String, ByVal
Reserved As Integer, ByVal dwType As Integer, ByRef lpData As Any, ByVal
cbData As Integer) As Integer

Private Declare Function RegEnumValue Lib "advapi32.dll" Alias
"RegEnumValueA"(ByVal hKey As Integer, ByVal dwIndex As Integer, ByVal
lpValueName As String, ByRef lpcbValueName As Integer, ByVal lpReserved As
Integer, ByRef lpType As Integer, ByRef lpData As Any, ByRef lpcbData As
Integer) As Integer

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"(ByVal
hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal
lParam As Any) As Integer

Private Declare Function OSWinHelp Lib "user32" Alias "WinHelpA"(ByVal hwnd
As Integer, ByVal HelpFile As String, ByVal wCommand As Short, ByRef dwData
As Any) As Short Const EM_UNDO As Short = &HC7s

I'm sure I can't be the only person to come accross this. Is there a list
of these common calls someplace that tells me the proper values to replace
the "As Any" with?


 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      6th Apr 2004
"Lance Geeck" <(E-Mail Removed)> schrieb
> I have many items that I lifted off from Microsoft's website several
> years ago. These samples were in VB6.
>
> I now want to convert an application to VB.NET. I am getting an
> error that says "As Any is not supported in a declare statement"
> during the automated
> Conversion process.
>
> Some examples of this are:
> [...]


Replace As Any by another data type. You can overload declarations to use
different types.

See also
http://msdn.microsoft.com/library/en...indowsAPIs.asp
and the linked topics, like
http://msdn.microsoft.com/library/en...lfunctions.asp
and
http://msdn.microsoft.com/library/en...marshaling.asp

Be careful when strings are returned byref: Use a stringbuilder instead.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Overrides Declare Function "X.dll"? Joe HM Microsoft VB .NET 2 1st Nov 2007 04:16 PM
Re: Declare Function GetPrivateProfileInt% Lib "Kernel" Nicholas Paldino [.NET/C# MVP] Microsoft C# .NET 0 29th Mar 2007 09:44 PM
Update Command gives "Must Declare scalar variable "@P7CYCELDAY"" craig Microsoft ADO .NET 2 27th Dec 2006 02:03 PM
Declare Auto Function BitBlt Lib "GDI32.DLL" (...) Qwert Microsoft VB .NET 0 6th Mar 2005 03:11 PM
"Public Overrides Declare Function" possible in any other way? Benjamin Lukner Microsoft VB .NET 0 1st Sep 2004 12:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:33 PM.