我有一个.CS文件,它使用SQL来检索一些数据并从.VB文件中调用:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim urgentcare As New UrgentCareWaitTime()
'' Urgent Care Display
'' RGENT CARE 1 THEALL RD
lbl_time.Text = urgentcare.Show("195", Labeltheall)
''new roc
lbl_time.Text = urgentcare.Show("542", Label171)
''ridge hills
lbl_time.Text = urgentcare.Show("470", Labelridge)
'' 210
lbl_time.Text = urgentcare.Show("194", Label210)
End Sub
Protected Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim urgentcare As New UrgentCareWaitTime()
'' Urgent Care Display
'' RGENT CARE 1 THEALL RD
urgentcare.Show("195", Labeltheall)
''new roc
urgentcare.Show("542", Label171)
''ridge hills
urgentcare.Show("470", Labelridge)
'' 210
urgentcare.Show("194", Label210)
End Sub
在我的ASP.NET文件中,我有一些文本框:
<asp:Label ID="Labeltheall" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label171" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Label210" runat="server" Text="Label"></asp:Label>
<br />
<asp:Label ID="Labelridge" runat="server" Text="Label"></asp:Label>
<br />
Last Updated: <asp:Label runat="Server" id=lbl_time />
我的asp页面是Default.aspx
,帮助文件是Default.aspx.cs
。如何将VB代码转换为CS,以便我可以在我的帮助文件中使用它来更新那些asp标签?
答案 0 :(得分:2)
你去吧
protected void Page_Load(object sender, System.EventArgs e)
{
UrgentCareWaitTime urgentcare = new UrgentCareWaitTime();
lbl_time.Text = urgentcare.Show("195", Labeltheall);
lbl_time.Text = urgentcare.Show("542", Label171);
lbl_time.Text = urgentcare.Show("470", Labelridge);
lbl_time.Text = urgentcare.Show("194", Label210);
}
protected void Timer1_Tick(System.Object sender, System.EventArgs e)
{
UrgentCareWaitTime urgentcare = new UrgentCareWaitTime();
urgentcare.Show("195", Labeltheall);
urgentcare.Show("542", Label171);
urgentcare.Show("470", Labelridge);
urgentcare.Show("194", Label210);
}
要自己动手,请在此处复制并粘贴您的vb代码,然后点击CONVERT TO C#http://www.developerfusion.com/tools/convert/vb-to-csharp/
答案 1 :(得分:1)
ASP.Net源代码将相同,通过添加c#网页将.vb文件更改为.cs文件并将代码复制到converter.telerik.com
protected void Page_Load(object sender, System.EventArgs e)
{
UrgentCareWaitTime urgentcare = new UrgentCareWaitTime();
//' Urgent Care Display
//' RGENT CARE 1 THEALL RD
lbl_time.Text = urgentcare.Show("195", Labeltheall);
//'new roc
lbl_time.Text = urgentcare.Show("542", Label171);
//'ridge hills
lbl_time.Text = urgentcare.Show("470", Labelridge);
//' 210
lbl_time.Text = urgentcare.Show("194", Label210);
}
protected void Timer1_Tick(System.Object sender, System.EventArgs e)
{
UrgentCareWaitTime urgentcare = new UrgentCareWaitTime();
//' Urgent Care Display
//' RGENT CARE 1 THEALL RD
urgentcare.Show("195", Labeltheall);
//'new roc
urgentcare.Show("542", Label171);
//'ridge hills
urgentcare.Show("470", Labelridge);
//' 210
urgentcare.Show("194", Label210);
}
答案 2 :(得分:1)
使用在线Vb to C# converter。
否则 这是您的C#代码
protected void Page_Load(object sender, System.EventArgs e)
{
UrgentCareWaitTime urgentcare = new UrgentCareWaitTime();
lbl_time.Text = urgentcare.Show("195", Labeltheall);
lbl_time.Text = urgentcare.Show("542", Label171);
lbl_time.Text = urgentcare.Show("470", Labelridge);
lbl_time.Text = urgentcare.Show("194", Label210);
}
protected void Timer1_Tick(System.Object sender, System.EventArgs e)
{
UrgentCareWaitTime urgentcare = new UrgentCareWaitTime();
urgentcare.Show("195", Labeltheall);
urgentcare.Show("542", Label171);
urgentcare.Show("470", Labelridge);
urgentcare.Show("194", Label210);
}
希望它有所帮助。
答案 3 :(得分:0)
protected void Page_Load(object sender, System.EventArgs e)
{
UrgentCareWaitTime urgentcare = new UrgentCareWaitTime();
//' Urgent Care Display
//' RGENT CARE 1 THEALL RD
lbl_time.Text = urgentcare.Show("195", Labeltheall);
//'new roc
lbl_time.Text = urgentcare.Show("542", Label171);
//'ridge hills
lbl_time.Text = urgentcare.Show("470", Labelridge);
//' 210
lbl_time.Text = urgentcare.Show("194", Label210);
}
protected void Timer1_Tick(System.Object sender, System.EventArgs e)
{
UrgentCareWaitTime urgentcare = new UrgentCareWaitTime();
//' Urgent Care Display
//' RGENT CARE 1 THEALL RD
urgentcare.Show("195", Labeltheall);
//'new roc
urgentcare.Show("542", Label171);
//'ridge hills
urgentcare.Show("470", Labelridge);
//' 210
urgentcare.Show("194", Label210);
}