Results 1 to 4 of 4

Thread: vb6 /vba call .net com object CLRHost

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    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

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    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

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: vb6 /vba call .net com object CLRHost

    This is some very interesting stuff.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: vb6 /vba call .net com object CLRHost

    Quote Originally Posted by xiaoyao View Post
    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.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width