将VB代码转换为VB.NET
问题描述:
在将下面的代码从VB转换为VB.NET时,我遇到了一些问题
I am having some problem during convert below code from VB to VB.NET
Dim LCID As Integer
Dim newFormat As String
LCID = GetSystemDefaultLCID()
newFormat = d1
Call SetLocaleInfo(LCID, LOCALE_SSHORTDATE, newFormat)
Call PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0)
Call EnumDateFormats(AddressOf EnumCalendarDateProc,LCID,DATE_SHORTDATE)
但这会导致addressof
语法出错.
如何在
中表示AddressOf
语法
Call EnumDateFormats(AddressOf EnumCalendarDateProc, LCID,DATE_SHORTDATE)
在将VB应用程序转换为VB.NET时
But it gives error in addressof
syntax.
How can I represent AddressOf
syntax in Call EnumDateFormats(AddressOf EnumCalendarDateProc, LCID,DATE_SHORTDATE)
when converting VB application to VB.NET
答
您正在尝试调用Windows API方法,这些方法无法从.Net直接访问. br/>
您需要导入System.Runtime.InteropServices
并了解Invoke
.前往tis网站获取.Net的Windows API原型:
pinvoke.net [
You''re trying to call Windows API methods that aren''t directly accessible from .Net.
You need to import theSystem.Runtime.InteropServices
and learn aboutInvoke
. Go to tis site for windows API prototypes for .Net:
pinvoke.net[^]
They have both VB and C# examples for most functions.