如何把这段VB.net转换成 C#代码?

hemudu 2004-12-27 03:23:43
<%@ Page Language="VB" AutoEventWireup="false" aspcompat=true %>
<script language="VB" runat="server">
Dim objMyCOM As Object
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
objMyCOM = Server.CreateObject("ServerCtrl1.DBInterface")
objMyCOM = Nothing
End If
End Sub
</script>
...全文
167 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
hemudu 2005-01-03
  • 打赏
  • 举报
回复
up
hemudu 2004-12-30
  • 打赏
  • 举报
回复
现在用vb.net可以使用的,但我已经习惯用c#,且程序的其他代码都是C#写的。
hemudu 2004-12-30
  • 打赏
  • 举报
回复
已经复制到bin目录了
Richardhu 2004-12-28
  • 打赏
  • 举报
回复
你的计算机安装了这个ServerCtrl1.DBInterface组件了吗,查查.
hemudu 2004-12-27
  • 打赏
  • 举报
回复
我搜索了一下csdn的贴了,其中一位用强类型转换,但我这里试了一下,还是不对。

给我想想办法,纳闷中
hemudu 2004-12-27
  • 打赏
  • 举报
回复
我的这个问题估计不是一般转换的语法问题?估计还要考虑其他的问题?

有没有那位用过COM组件c#的?
qwjcool 2004-12-27
  • 打赏
  • 举报
回复
up
gigicat 2004-12-27
  • 打赏
  • 举报
回复
<%@ Page Language="C#" AutoEventWireup="false" aspcompat=true %>
<script language="C#" runat="server">
object objMyCOM ;
void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
objMyCOM = Server.CreateObject("ServerCtrl1.DBInterface");
objMyCOM = null;
}
}
</script>
goody9807 2004-12-27
  • 打赏
  • 举报
回复
http://www.developerfusion.com/utilities/convertvbtocsharp.aspx
hemudu 2004-12-27
  • 打赏
  • 举报
回复
COM组件真奇怪!!!
看来看去vb.net跟c#的转换是正确的,不知还要修改什么?
hemudu 2004-12-27
  • 打赏
  • 举报
回复
我也是这样转换的,就是不对啊
VB.net能运行,c#就不可以了
=========================
Server Error in '/' Application.
--------------------------------------------------------------------------------

Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>


welshem 2004-12-27
  • 打赏
  • 举报
回复
<%@ Page Language="CC#VB" runat="server">
object objMyCOM;
void Page_Load(object sender, EventArgs e)
{
if(! this.IsPostBack)
{
objMyCOM = Server.CreateObject("ServerCtrl1.DBInterface");
objMyCOM = null;
}
}
</script>
Richardhu 2004-12-27
  • 打赏
  • 举报
回复
private object objMyCOM;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
objMyCOM = Server.CreateObject("ServerCtrl1.DBInterface");
objMyCOM = null;
}
}
rickjelly2004 2004-12-27
  • 打赏
  • 举报
回复
object objMyCOM;
rickjelly2004 2004-12-27
  • 打赏
  • 举报
回复
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack) {
objMyCOM = Server.CreateObject("ServerCtrl1.DBInterface");
objMyCOM = null;
}
}

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧