Option Explicit On
創新互聯長期為近1000家客戶提供的網站建設服務,團隊從業經驗10年,關注不同地域、不同群體,并針對不同對象提供差異化的產品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯網生態環境。為陽春企業提供專業的網站建設、成都網站建設,陽春網站改版等技術服務。擁有10多年豐富建站經驗和眾多成功案例,為您定制開發。
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 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#的,我用過,還可以的,但是轉后也要改動一些。這里還有將c#轉vb.net的。
這是我轉的:
string[] ArrValue = new string[43];
int Nums;
public void Page_Load(object Sender, EventArgs E)
{
int I;
if (!IsPostBack) {
for (I = 1900; I = 2101; I++) {
ListItem IItem = new ListItem();
IItem.Text = (string)I;
if (I == Year(Now)) {
IItem.Selected = "True";
}
DropYear.items.add(IItem);
}
for (I = 1; I = 12; I++) {
ListItem IItem = new ListItem();
IItem.Text = (string)I;
if (I == Month(Now)) {
IItem.Selected = "True";
}
DropMonth.items.add(IItem);
}
}
DispDetail(Conversion.Val(DropYear.SelectedItem.Text), Conversion.Val(DropMonth.SelectedItem.Text));
}
public void DispDetail(int YYear, int MMonth)
{
System.DateTime theDate;
int theYear;
int theMonth;
int theDay;
int theWeek;
int theFirstNum;
int NumOfMonth;
int i;
string theStr;
theYear = YYear;
theMonth = MMonth;
theDay = 1;
//獲得所要查詢的月的第一天日期
theDate = DateSerial(theYear, theMonth, theDay);
//確定所要查詢的第一天是星期幾
theWeek = weekday(theDate);
theFirstNum = theWeek;
//確定所要查詢的月的天數
NumOfMonth = GetDayNum(theyear, themonth);
for (i = 0; i = 41; i++) {
ArrValue(i) = "";
}
for (i = 0; i = NumOfMonth - 1; i++) {
ArrValue(theFirstNum - 1 + i) = i + 1;
}
}
public object GetDayNum(int YYear, int MMonth)
{
object functionReturnValue = null;
if (MMonth == 1 | MMonth == 3 | MMonth == 5 | MMonth == 7 | MMonth == 8 | MMonth == 10 | MMonth == 12) {
functionReturnValue = 31;
}
else {
if (MMonth == 4 | MMonth == 6 | MMonth == 9 | MMonth == 11) {
functionReturnValue = 30;
}
else {
if (((YYear % 4 == 0) (YYear % 100 != 0)) | (YYear % 400 == 0)) {
functionReturnValue = 29;
}
else {
functionReturnValue = 28;
}
}
}
return functionReturnValue;
}
Option 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
可以試試VBto Converter
VBto Converter是一款VB語言轉換軟件,它支持將MS Visual Basic資源文件(包括源代碼)轉換成MS VC++ MFC, VC++.NET (CLR), VBNET, C#, J#, Borland C++ Builder, Borland Delphi源文件。
強制類型轉換在VB.NET中用Ctype()函數實現的。
Dim drv As DataRowView = CType(comboBox1.SelectedItem, DataRowView)
另外:comboBox1.SelectedItem 不是 string 類型,而是 object 類型。ComboBox 下拉顯示文字是通過調用 Object.ToString() 方法實現的。
首先是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
運行結果:
文章標題:vb.net完整轉化c#,VB轉C#
當前鏈接:http://vcdvsql.cn/article40/heoseo.html
成都網站建設公司_創新互聯,為您提供用戶體驗、關鍵詞優化、網頁設計公司、企業網站制作、網站制作、動態網站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯