重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net代码转换c vb60转net

vb.net代码翻译成c#代码!

public string GetAllData(bool Verbose = true)

创新互联是一家专业的成都网站建设公司,我们专注成都网站设计、成都网站制作、网络营销、企业网站建设,买友情链接广告投放为企业客户提供一站式建站解决方案,能带给客户新的互联网理念。从网站结构的规划UI设计到用户体验提高,创新互联力求做到尽善尽美。

{

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 = i + 1;

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语言编写的代码改成c#

给你个网站看

可在线将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;

}

怎样将VB代码换成C

可以试试VBto Converter

VBto Converter是一款VB语言转换软件,它支持将MS Visual Basic资源文件(包括源代码)转换成MS VC++ MFC, VC++.NET (CLR), VBNET, C#, J#, Borland C++ Builder, Borland Delphi源文件。

vb.net 转 c#

--VB--

Public Function ff() As Boolean

ff=true

End Function

--C#

public bool ff()

{

return true;

}

----

这里的 ff=true 是相当于 C#里的 return true; 是给vb函数自身返回值用的.

--VB--

Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ff=true 'vb里可以省略函数的小括号()

End Sub

--C#--

private void Form_Load(System.Object sender, System.EventArgs e)

{

ff() == true;

}

这里的 ff=true 是相当于 C#里的 ff() == true; 是判断.


新闻标题:vb.net代码转换c vb60转net
本文路径:http://cqcxhl.com/article/hggohi.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP