vb.net项目转c vb 类型转换

如何把下面用vb.net语言编写的代码改成c#给vb.net项目转c你个网站看
可在线将vb.net代码转成c#的vb.net项目转c , 我用过vb.net项目转c,还可以的vb.net项目转c , 但是转后也要改动一些 。这里还有将c#转vb.net的 。
这是我转的:
string[] ArrValue = https://www.04ip.com/post/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 - 1i) = i1;
}
}
public object GetDayNum(int YYear, int MMonth)
{
object functionReturnValue = https://www.04ip.com/post/null;
if (MMonth == 1 | MMonth == 3 | MMonth == 5 | MMonth == 7 | MMonth == 8 | MMonth == 10 | MMonth == 12) {
functionReturnValue = https://www.04ip.com/post/31;
}
else {
if (MMonth == 4 | MMonth == 6 | MMonth == 9 | MMonth == 11) {
functionReturnValue = https://www.04ip.com/post/30;
}
else {
if (((YYear % 4 == 0)(YYear % 100 != 0)) | (YYear % 400 == 0)) {
functionReturnValue = https://www.04ip.com/post/29;
}
else {
functionReturnValue = https://www.04ip.com/post/28;
}
}
}
return functionReturnValue;
}
怎样将VB代码换成C可以试试VBto Converter
VBto Converter是一款VB语言转换软件vb.net项目转c,它支持将MS Visual Basic资源文件(包括源代码)转换成MS VCMFC, VC.NET (CLR), VBNET, C#, J#, Borland CBuilder, Borland Delphi源文件 。
vb.net代码翻译成c#代码!public string GetAllData(bool Verbose = true)
{
ListViewItem lvi = default(ListViewItem);
try {
ports.Serial.settings.SetStandard(MyPort, 9600, 0);
ports.Serial.settings.useDTR = 1;
ports.Serial.settings.useRTS = 1;
if ((ports.Serial.Open() == false)) {
return "Failed To Open Port";
}
if (Verbose) {
lvi = status.setMessage("WeatherDuck", "Data Sample", "Begin", true);
lvi.ForeColor = System.Drawing.Color.Blue;
}
System.Threading.Thread.Sleep(por_delay);
ports.Serial.FlushRcv();
ports.Serial.SendString("T");
System.Threading.Thread.Sleep(read_delay);
string Temperature = ports.Serial.ReadString();
if ((Temperature.Length == 0))
return "Failed To Read Temperature";
char[] split = ",".ToCharArray();
string[] temp = Temperature.Split(split, 2);
_tempC = temp[0];
_tempF = temp[1];
if (Verbose)
lvi.SubItems(2).Text = "Done Temperature";
ports.Serial.SendString("H");
System.Threading.Thread.Sleep(read_delay);
_humidity = ports.Serial.ReadString();
if ((_humidity.Length == 0))
return "Failed To Read Humidity";
if (Verbose)
lvi.SubItems(2).Text = "Done Humidity";
ports.Serial.SendString("L");
System.Threading.Thread.Sleep(read_delay);
_lightlevel = ports.Serial.ReadString();
if ((_lightlevel.Length == 0))
return "Failed To Read LightLevel";
if (Verbose)
lvi.SubItems(2).Text = "Done Light Level";
ports.Serial.SendString("F");
System.Threading.Thread.Sleep(read_delay);
_airflow = ports.Serial.ReadString();
if ((_airflow.Length == 0))
return "Failed To Read Air Flow";
if (Verbose)
lvi.SubItems(2).Text = "Done Air Flow";
int i = 0;
while ((true)) {
i = i1;
if ((i = sound_delay))
break; // TODO: might not be correct. Was : Exit While
System.Threading.Thread.Sleep(500);
if (Verbose)
lvi.SubItems(2).Text = "Sampling Sound Level:"i.ToString();
}
ports.Serial.SendString("S");
System.Threading.Thread.Sleep(read_delay);
_soundlevel = ports.Serial.ReadString();
ports.Serial.SendString("S");
System.Threading.Thread.Sleep(read_delay);
_soundlevel = ports.Serial.ReadString();
if ((_soundlevel.Length == 0))
return "Failed To Read Sound Level";
return "Success";
} catch (Exception bug) {
if (Verbose)
status.setMessage("WeatherDuck", bug.Message, "Error", false);
return "Exception During Get Data: "bug.Message;
} finally {
ports.Serial.Close();
if (Verbose) {
lvi = status.setMessage("WeatherDuck", "Data Sample", "Done", true);
lvi.ForeColor = System.Drawing.Color.Blue;
lvi = status.setMessage("WeatherDuck", "Port Status", "Closed", true);
lvi.ForeColor = System.Drawing.Color.Blue;
}
}
}
VB.NET object 转换到C#object问题你实例化对象看看哈
VB 和C#的object 在变异的时候是不一样的,你不做修改正常出错
object指对象,代表的是通用的对象,就是什么对象都可以表示 , new只能表示固定的对象
还有注意一下大小写object和Object是不一样的
在vs2008中怎样将vb的项目转换成c#的项目?这需要三个步骤:
第一步:创建一个C#项目vb.net项目转c,在其中添加相应的窗体和引用,将VB2008中相应窗体上的控件复制到C#相应的窗体上;
第二步:使用C#与VB.NET转换工具软件或者到“”,将VB2008 的代码转换成C#代码 。
第三步:工具软件或者在线转换 , 转换后的代码会有一些错误或者无法转换的部分,进行简单的人工修正 。
OK,vb.net项目转c你成功vb.net项目转c了vb.net项目转c!
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
运行结果:
【vb.net项目转c vb 类型转换】vb.net项目转c的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于vb 类型转换、vb.net项目转c的信息别忘了在本站进行查找喔 。

    推荐阅读