惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

博客园 - 天涯

Prism.Interactivity 和 Prism.Modularity 介绍 Prism BindableBase 和 Commands 的介绍 对 mvvm 架构的理解 wpf mvvm 架构 C#硬件开发业务流程调试技巧 wpf winform 截图 wpf Cannot locate resource 'app.xaml' app.config ConfigSection 保护 程序开发注意4项,你知道吗? .net 变量缓存,你知道吗 wpf 多线程 更新UI 界面 wpf treeview 绑定不同的对象 .net 技术,你掌握了多少 aspx 中确认删除 脚本 - 天涯 .net 中对类的扩展 奇怪--ORA-12154:TNS:无法处理服务名: 建模十条原则 由软件加壳谈起 Hashtable 应注意的 2 点
vb 调用c#做的com 组件
天涯 · 2007-11-07 · via 博客园 - 天涯

1:建立c# 项目 (注意项目必须含有接口,其他类应该实现该接口,才可以在其他语言中用该com组件)
2:将 AssemblyInfo.cs 里的 [assembly: ComVisible(false)] 改为 true
3:项目-属性-生成里将:为com interop 注册 选种
4:生成后就可以在其他语言中引用或该组件。
一般代码如下:
 

using System;
using System.Collections.Generic;
using System.Text;

namespace UseMethod
{
    public interface IField
    {
        void SetField(UseMethod.Fields f);
        UseMethod.Fields GetField();
        UseMethod.Fields GetSetField(UseMethod.Fields f);
        int Add(int i, int j);
    }

  public class FieldAction:IField
    {
        public FieldAction()
        {

            //如果使用设计的组件,请取消注释以下行
            //InitializeComponent();
        }

        public void SetField(UseMethod.Fields f)
        {
            Fields f1 = new Fields();
            f1.city = "city";
            f1.country = "country";
            f1.myCity = "nycity";
            f1.myName = "myName";
        }
        public UseMethod.Fields GetField()
        {
            Fields f1 = new Fields();
            f1.city = "city";
            f1.country = "country";
            f1.myCity = "nycity";
            f1.myName = "myName";
            return f1;
        }
        public UseMethod.Fields GetSetField(UseMethod.Fields f)
        {

            return f;
        }
        public int Add(int i, int j)
        {
            return i + j;
        }
}
 public class Fields
    {
        public string city;
        public string country;
        public string myName;
        public string myCity;
    }

   
} 当然可以有其他复杂的类,但是在操作时,最好用强类型,以便于识别!

将生成的

UseMethod.tlb 即.tlb文件引用到vb的项目中,然后 
在vb6中调用:
  

Private Sub cmdObject_Click()

Dim meth As UseMethod.IField
Dim met As UseMethod.FieldAction
Dim result As UseMethod.Fields

Dim fi As UseMethod.Fields
Set fi = New UseMethod.Fields
Set met = New UseMethod.FieldAction

With fi
.city = "city"
.country = "country"
.myName = "myName"
.myCity = "MYcITR"
End With
Set meth = met

txtStr.Text = meth.Add(8, 9)

Set result = meth.GetSetField(fi)
 txtInOut.Text = result.city & result.country //注意这里的属性应和c#里定义的一样
MsgBox "soapClient3.AddressName", vbDefaultButton1, "提示"
End Sub