真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

c與vb.net互轉(zhuǎn) vb60轉(zhuǎn)net

vb.net 調(diào)用C語(yǔ)言可執(zhí)行程序并傳值?

在c語(yǔ)言中每一個(gè)變量都有兩個(gè)屬性一個(gè)是值,一個(gè)是址。比如inta=2;變量a的值是2,變量a的地址,可以用取地址

創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括石臺(tái)網(wǎng)站建設(shè)、石臺(tái)網(wǎng)站制作、石臺(tái)網(wǎng)頁(yè)制作以及石臺(tái)網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,石臺(tái)網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到石臺(tái)省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

操作符

獲取,即a。因此以C語(yǔ)言的函數(shù)傳遞中具備兩種方式傳遞參數(shù),一種是傳址,一種傳值。比如voidf1(intv){;}//函數(shù)f1v

請(qǐng)幫忙將以下C語(yǔ)言代碼轉(zhuǎn)換為VB.NET代碼,謝謝!

Option Explicit On

Option Strict On

Imports System

Module Program

Sub Main()

Dim y,m,t As Integer

begin:

' 輸入數(shù)據(jù)時(shí)一行一個(gè)

y=CInt(Console.ReadLine())

m=CInt(Console.ReadLine())

t=CInt(Console.ReadLine())

If y100 Then

y=y+2000

End If

If y1916 OrElse m200 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

Console.WriteLine(" {0}-{1} ~ {2}-{3}",y,m,ye,[Me])

ye=y

[Me]=m

For i=0 To t-1

prmonth(ye,[me])

[Me]=[Me]+1

If [Me]12 Then

ye=ye+1

[me]=1

End If

Next

Return 0

End Function

Function yam(y As Integer,m As Integer) As Integer

Dim st As String()={"未定義","一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"}

Console.WriteLine(" {0} {1}",y,st(m))

Console.WriteLine("----------------------------")

Return 0

End Function

Function ryear(y As Integer) As Integer

If 0=y Mod 400 OrElse (0y Mod 100 AndAlso 0=y Mod 4) Then

Return 1

Else

Return 0

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 Integer=0

If 2=m Then

ad=ryear(y)

End If

Return day(m)+ad

End Function

Function monday(y As Integer,m As Integer) As Integer

Dim md As Integer=6

Dim i,daynum As Integer

For i=1916 To y-1

daynum=365+ryear(i)

md=(md+daynum) Mod 7

Next

For i=1 To m-1

md=(md+mday(y,i)) Mod 7

Next

Return md

End Function

Function prmonth(y As Integer,m As Integer) As Integer

Dim md As Integer=monday(y,m)

Dim daysnum As Integer=mday(y,m)

Dim days As Integer=daysnum+md

Dim i As Integer

yam(y,m)

Console.Write(" 日 一 二 三 四 五 六")

For i=0 To days-1

If 0=i Mod 7 Then

Console.WriteLine()

Console.WriteLine()

Console.Write(" ")

End If

If i-md=0 Then

Console.Write(" {0,2}",i-md+1)

Else

Console.Write(" ")

End If

Next

Console.WriteLine()

Console.WriteLine()

Return 0

End Function

End Module

vb.net如何與c語(yǔ)言做的dll互相傳遞字符串

首先是C的DLL(我的項(xiàng)目叫ConsoleApplication2.dll):

#include?Windows.h

//?導(dǎo)出Test函數(shù),供外部使用

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項(xiàng)目:

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

運(yùn)行結(jié)果:

如何在vb.net調(diào)用c程序

------------------------------------------00000000000000000000000000++++++++++++++++++

C語(yǔ)言轉(zhuǎn)換為VB.NET

Option Explicit On

Option Strict On

Imports System

Module Program

Sub Main()

Dim y,m,t As Integer

begin:

' 輸入數(shù)據(jù)時(shí)一行一個(gè)

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


當(dāng)前文章:c與vb.net互轉(zhuǎn) vb60轉(zhuǎn)net
當(dāng)前URL:http://weahome.cn/article/hjoiod.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部