vb2clr
1.0.0
Visual Basic for Applications (VBA) 7.0 的幫助程式類別CLRHost ,提供對 CLR (.NET Framework) 組件和類別的存取。
若要使用 .NET(以前稱為 .NET Core),請考慮使用 vb2net。
Visual Basic for Application 7.0(包含在 Microsoft Office 2010 或更高版本中)
LongPtr重寫為Long並刪除所有PtrSafe說明符。 CLRHost類別編寫程式碼CLRHost實例或呼叫Terminate方法。True傳遞給CLRHost.Initialize的TerminateOnExit參數,則在中斷或暫停應用程式時不得停止偵錯器。ExitHandler模組中的程式碼在暫停期間停止時無法運行,並且應用程式(包括Excel等VBA主機)可能會導致崩潰。.utf8.*文件,刪除日文註釋,然後匯入它們。 Public Sub RegexSample()
Dim host As New CLRHost
Call host.Initialize(False)
On Error Resume Next
Dim asmSys As mscorlib.Assembly
Set asmSys = host.CLRLoadAssembly("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
Dim cobjRegex As mscorlib.Object
Set cobjRegex = host.CLRCreateObjectWithParams("System.Text.RegularExpressions.Regex", _
"([0-9])+")
Dim cobjColl As mscorlib.Object
Set cobjColl = host.CLRInvokeMethod(cobjRegex, "Matches", "10 20 50 1234 98765")
Dim vMatch As Variant
For Each vMatch In host.ToEnumerable(cobjColl)
Dim cobjMatch As mscorlib.Object
Set cobjMatch = vMatch
Debug.Print "Matches: "; host.CLRProperty(cobjMatch, "Value")
Set cobjMatch = Nothing
Next vMatch
vMatch = Empty
Set cobjColl = Nothing
Set cobjRegex = Nothing
'Call host.Terminate
Set host = Nothing
End Sub
噴射機(@jet2jet)
新 BSD 授權(或 3 條款 BSD 授權)