c与vb.net互转 vb转c++工具

C语言转换为VB.NETOption Explicit On
Option Strict On
Imports System
Module Program
Sub Main()
Dim y,m,t As Integer
begin:
' 输入数据时一行一个
y=CInt(Console.ReadLine())
m=CInt(Console.ReadLine())
t=CInt(Console.ReadLine())
If y
200 Then
Console.WriteLine("ERROR")
goto begin
End If
pr(y,m,t)
Console.Write("Press any key to continue . . . ")
Console.ReadKey(True)
End Sub
Function pr(y As Integer,m As Integer,t As Integer) As Integer
Dim ye,[Me],i As Integer
ye=CInt((m+t-2)/12+y)
[Me]=(m+t-2) Mod 12+1
End If
End Function
Function mday(y As Integer,m As Integer) As Integer
Dim day As Integer()={0,31,28,31,30,31,30,31,31,30,31,30,31}
Dim ad As I
C# to vb.net 代码转换System.Runtime.InteropServices.DllImport("user32.dll") _
Public Shared Function SetWindowLong(hWnd As IntPtr, nIndex As Integer, wndproc As Integer) As Integer
End Function
System.Runtime.InteropServices.DllImport("user32.dll") _
Public Shared Function GetWindowLong(hWnd As IntPtr, nIndex As Integer) As Integer
End Function
Public Const GWL_STYLE As Integer = -16
Public Const WS_DISABLED As Integer = H8000000
Public Shared Sub SetControlEnabled(c As Control, enabled As Boolean)
【c与vb.net互转 vb转c++工具】If enabled Then
SetWindowLong(c.Handle, GWL_STYLE, (Not WS_DISABLED) And GetWindowLong(c.Handle, GWL_STYLE))
Else
SetWindowLong(c.Handle, GWL_STYLE, WS_DISABLED + GetWindowLong(c.Handle, GWL_STYLE))
End If
End Sub
授人以渔c与vb.net互转:
这个网站超牛逼
在vs2008中怎样将vb的项目转换成c#的项目?这需要三个步骤:
第一步:创建一个C#项目,在其中添加相应的窗体和引用,将VB2008中相应窗体上的控件复制到C#相应的窗体上;
第二步:使用C#与VB.NET转换工具软件或者到“”,将VB2008 的代码转换成C#代码 。
第三步:工具软件或者在线转换,转换后的代码会有一些错误或者无法转换的部分,进行简单的人工修正 。
OK,你成功了!
vb.net如何与c语言做的dll互相传递字符串首先是C的DLL(我的项目叫ConsoleApplication2.dll):
#include Windows.h
// 导出Test函数 , 供外部使用
extern "C" __declspec(dllexport) BSTR __cdecl Test(LPSTR p);
BOOL WINAPI DllMain(
HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH: break;
case DLL_THREAD_ATTACH: break;
case DLL_THREAD_DETACH: break;
case DLL_PROCESS_DETACH: break;
}
return TRUE;
}
BSTR __cdecl Test(LPSTR p)
{
p[0] = 'X';
return SysAllocString((BSTR)p);
}
然后是VB.Net项目:
Imports System.Runtime.InteropServices
Imports System.Text
Module Module1
REM 生成的是ConsoleApplication2.dll,名字与C里面相同
DllImport("ConsoleApplication2.dll", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.Cdecl)
Public Function Test(MarshalAs(UnmanagedType.LPTStr) ByVal str As StringBuilder) As MarshalAs(UnmanagedType.BStr) String
End Function
Sub Main()
Dim str As StringBuilder = New StringBuilder("Hello")
Dim rstr As String = Test(str)
Console.WriteLine(rstr)
Console.ReadKey()
End Sub
End Module
运行结果:
关于c与vb.net互转和vb转c++工具的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读