Option Explicit On
創(chuàng)新互聯(lián)長(zhǎng)期為近1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為陽春企業(yè)提供專業(yè)的網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè),陽春網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
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
給你個(gè)網(wǎng)站看
可在線將vb.net代碼轉(zhuǎn)成c#的,我用過,還可以的,但是轉(zhuǎn)后也要改動(dòng)一些。這里還有將c#轉(zhuǎn)vb.net的。
這是我轉(zhuǎn)的:
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;
//確定所要查詢的月的天數(shù)
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:
' 輸入數(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
可以試試VBto Converter
VBto Converter是一款VB語言轉(zhuǎn)換軟件,它支持將MS Visual Basic資源文件(包括源代碼)轉(zhuǎn)換成MS VC++ MFC, VC++.NET (CLR), VBNET, C#, J#, Borland C++ Builder, Borland Delphi源文件。
強(qiáng)制類型轉(zhuǎn)換在VB.NET中用Ctype()函數(shù)實(shí)現(xiàn)的。
Dim drv As DataRowView = CType(comboBox1.SelectedItem, DataRowView)
另外:comboBox1.SelectedItem 不是 string 類型,而是 object 類型。ComboBox 下拉顯示文字是通過調(diào)用 Object.ToString() 方法實(shí)現(xiàn)的。
首先是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é)果: