资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net与c转换 vb进制转换

请大侠帮我将C代码转换成VB.Net,谢谢!

public function Calculate_CRC8(byval crc as uint16,byval n as uint16) as uint16

专注于为中小企业提供成都做网站、网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业聊城免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了成百上千企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

dim i as uint16

crc=crc xor n

for i=0 to 7

if crc and 1 then

crc=(crc1) xor H8c

else

crc=crc1

end if

next

return crc

end function

vb.net中的数据强制转化问题,谁帮我把这段C#转化为VB.net的语言

强制类型转换在VB.NET中用Ctype()函数实现的。

Dim drv As DataRowView = CType(comboBox1.SelectedItem, DataRowView)

另外:comboBox1.SelectedItem 不是 string 类型,而是 object 类型。ComboBox 下拉显示文字是通过调用 Object.ToString() 方法实现的。

请帮忙将以下C语言代码转换为VB.NET代码,谢谢!

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 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#

--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#

给你个网站看

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

}

C语言转换为VB.NET

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


网站栏目:vb.net与c转换 vb进制转换
URL地址:http://cdkjz.cn/article/hjphod.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220