-
May 6th, 2023, 05:54 PM
#1
Thread Starter
PowerPoster
vb6 /vba call .net com object CLRHost
GitHub - jet2jet/vb2clr: The helper class for Visual Basic for Applications (VBA) 7.0, providing access to CLR (.NET Framework) assemblies and classes.
Code:
https://github.com/jet2jet/vb2clr
Visual Basic for Applications (VBA) 7.0 The helper class CLRHost, which provides access to the CLR (.NET Framework) assembly and classes.
(Study success: conversion to VB6)
'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.tlb
'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoree.tlb
'delete PtrSafe tag
'change info
'CLngPtr to clng
'LongPtr to long
Code:
Sub Main()
RegexSample
End Sub
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
vba transfer temporarily for a specific task. NET Object @VB Utilization. NET Components (Japan) Part 1-Programming Field, [powerful]
https://www.pg-fl.jp/program/tips/vb2clr1.htm
Use VBA Part 2 [Call] -CLR in the programming field (. NET)
https://www.pg-fl.jp/program/tips/vb2clr2.htm
Use CLR (. NET) Part 3 [Advanced Edition] in VBA-programming areas
https://www.pg-fl.jp/program/tips/vb2clr3.htm
-
May 6th, 2023, 09:31 PM
#2
Thread Starter
PowerPoster
Re: vb6 /vba call .net com object CLRHost
Assembly.LoadFrom HOW to do events (AddHandler )?-VBForums
https://www.vbforums.com/showthread....64#post5604664
i want to load com dll from vb.net
and make a vb.net dll for vb6
it's can load (*.dll) in vb6,callbyname,or bind events,how to do?
Code:
Code:
Dim sw As WebSocketServer = New WebSocketBuilder(8889).Build()
AddHandler sw.NewSessionConnected, AddressOf Sw_NewSessionConnected
-
May 6th, 2023, 09:57 PM
#3
Re: vb6 /vba call .net com object CLRHost
This is some very interesting stuff.
-
May 6th, 2023, 10:00 PM
#4
Re: vb6 /vba call .net com object CLRHost
Originally Posted by xiaoyao
and make a vb.net dll for vb6
it's can load (*.dll) in vb6,callbyname,or bind events,how to do?
Addhandler is not compatible with VB6.
Again, I really think you should be using COM interop instead. This is overkill for something like this. You don't need to go through all the trouble of loading the entire CLR yourself just to access .Net functionality.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|