VB调用C# DLL 传递数组参数问题
来源:互联网 发布:网络服务器硬盘回收 编辑:程序博客网 时间:2024/05/21 22:45
C# 端
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Collections;
namespace DonetToVBDll
{
//[ComVisible(true)]
//[Guid("F1DAF282-2FBC-4343-8CA7-EF8E277E0EEA")]
[ProgId("DonetToVBDll.clsComServer")]
[ClassInterface(ClassInterfaceType.None)]
public class clsComServer : IComServer
{
public int Add(int x, int y)
{
return x + y;
}
public int Subtract(int x, int y)
{
return x - y;
}
public string SayHello(string strName)
{
return strName + "你好,我是DoNetDLL,欢迎调用";
}
public string[] TransArray(string[] arr)
{
for (int i = 0; i < arr.Length; i++)
{
arr[i] = arr[i] + "Trans";
}
return arr;
}
}
}
Vb端
Option Explicit
Private Sub cmdAdd_Click()
Dim objDoNet As clsComServer
Dim lngResult As Long
Set objDoNet = New DonetToVBDll.clsComServer
lngResult = objDoNet.Add(CLng(txtX.Text), CLng(txtY.Text))
MsgBox lngResult
End Sub
Private Sub cmdSayHello_Click()
Dim objDoNet As Object
Dim strResult As String
Set objDoNet = CreateObject("DonetToVBDll.clsComServer")
strResult = objDoNet.SayHello(txtName.Text)
MsgBox strResult
End Sub
Private Sub cmdSubtract_Click()
Dim objDoNet As Object
Dim lngResult As Long
Set objDoNet = CreateObject("DonetToVBDll.clsComServer")
lngResult = objDoNet.Subtract(CLng(txtX.Text), CLng(txtY.Text))
MsgBox lngResult
End Sub
Private Sub cmdTransArr_Click()
Dim arr() As String
Dim objDoNet As Object
Dim arrGet() As String
ReDim arr(3)
arr(0) = "Limin"
arr(1) = "Ronaldo"
arr(2) = "Lixuefen"
arr(3) = "Rivaldo"
Set objDoNet = CreateObject("DonetToVBDll.clsComServer")
arrGet = objDoNet.TransArray(arr)
MsgBox UBound(arrGet)
End Sub
- VB调用C# DLL 传递数组参数问题
- C#调用vb dll 参数传递--数组、整型等(c#调用com)
- VB调用DLL时传递自定义类型数组参数注意
- VB调用C DLL时的参数传递问题
- C#调用C++dll 结构体参数传递问题
- C#调用C++dll 结构体参数传递问题
- C#调用C函数(DLL)传递参数问题
- C#调用C函数(DLL)传递参数问题
- 在VB中调用C/C++语言编写的dll,数组参数的传递
- 在VB中调用C/C++语言编写的dll,数组参数的传递
- 在VB中调用C/C++语言编写的dll,数组参数的传递
- C# 调用Dll 传递字符串指针参数
- C# 调用Dll 传递字符串指针参数
- C# 调用Dll 传递字符串指针参数
- VB调用VC DLL的参数问题
- VB传递数组参数
- C#调用c++的dll,结构体数组作为引用参数的传递方式
- C# 调用C++dll string传递问题
- Sqlmap注入技巧收集整理
- Android Launcher workspace缩略图实现
- eclipse使用技巧
- 技术团队新官上任之中层篇
- 博客收集
- VB调用C# DLL 传递数组参数问题
- 前置声明
- 类声明 classes
- eclipse反编译插件
- 从加藤嘉一身上我学到了
- 如何经营我们的大学
- 【开源专访】Fourinone创始人彭渊:打造多合一的分布式并行计算框架
- 企业员工弟子规
- 《狼图腾》狼的50格言