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 许可证)