VB到C#的转换 [英] VB to C# conversion

查看:312
本文介绍了VB到C#的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将VB代码转换为C#代码?

How can I convert this VB code to C# code?

abc = wb.Document;
abc.forms(0).all("login").value = "prtk@yahoo.com"

推荐答案

:laugh::laugh:...这已经是C#代码. VB不需要在每个行末端使用分号.

但我认为此C#代码中也存在错误,应该是:

:laugh: :laugh: ... This is already a C# code. VB dont need semicolon for each line end.

But I think there is error in this C# code as well, It should be :

abc = wb.Document;
abc.forms[0].all("login").value= "prtk@yahoo.com";


如果使用C#索引器,则应将其放在方括号内.


如果您需要与此等效的VB ...它将是:


In case of C# indexer should be placed inside square braces.


If you need VB equivalent to this ... it will be :

abc = wb.Document
abc.forms(0).all("login").value= "prtk@yahoo.com"




就是这样.




Thats it..


...这已经是C#代码了. VB不需要在每个行末端使用分号.

但我认为此C#代码中也存在错误,应该是:


abc = wb.Document; abc.forms [0] .all("login").value ="prtk@yahoo.com";
如果使用C#索引器,则应将其放在方括号内.


如果您需要与此等效的VB ...它将是:

abc = wb.Documentabc.forms(0).all("login").value ="prtk@yahoo.com"






先生,感谢您的答复,但它不起作用.实际上,我要做的是我正在使用c#进行代码编写并在silverlight3中进行设计..我正在制作Web应用程序...因为每个人都在输入用户名和密码很多网站..

我希望当用户在我的项目中输入其任何网站的用户名和密码时,应直接打开他的主页,这意味着我想为用户提供一种直接从我的项目中登录的功能.我..


我正在使用此代码

使用系统;
使用System.Collections.Generic;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControls;
使用System.Text;
使用SHDocVw;
使用mshtml;






公共局部类Default3:System.Web.UI.Page
{


受保护的void Page_Load(对象发送者,EventArgs e)
{



}
受保护的void Button1_Click(对象发送者,EventArgs e)
{
//mshtml.HTMLDocument abc;
//htmldocument abc;

HTMLDocument myDoc =新的HTMLDocumentClass();
myDoc.getElementsByName("form");

myDoc.getElementsByName("login");
myDoc.getElementsByName("passwd");
SHDocVw.InternetExplorer即=新的SHDocVw.InternetExplorerClass();
IWebBrowserApp wb =(IWebBrowserApp)ie;
wb.Visible = true;
对象o = null;
wb.Navigate("yahoomail.com",ref o,ref o,ref o,ref o);
myDoc = wb.Document;
myDoc.forms [0] .all("login").value ="prtk@yahoo.com";


}
}




但是它不起作用..给我一些代码提示

谢谢先生
... This is already a C# code. VB dont need semicolon for each line end.

But I think there is error in this C# code as well, It should be :


abc = wb.Document;abc.forms[0].all("login").value= "prtk@yahoo.com";
In case of C# indexer should be placed inside square braces.


If you need VB equivalent to this ... it will be :

abc = wb.Documentabc.forms(0).all("login").value= "prtk@yahoo.com"






sir thanks for the reply but its not working..actually what i want to do is that i am making the project as coding in c# and designing in silverlight3..I am making web application...As everyone has his username and password in lot of website..

I wants that when a user enter his username and password of any of his website in my project then his home page should be open directly,means I wants to give user a facility to directly login from my project..how can it possible please tell me..


I am doing with this code

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using SHDocVw;
using mshtml;






public partial class Default3 : System.Web.UI.Page
{


protected void Page_Load(object sender, EventArgs e)
{



}
protected void Button1_Click(object sender, EventArgs e)
{
// mshtml.HTMLDocument abc;
//htmldocument abc;

HTMLDocument myDoc = new HTMLDocumentClass();
myDoc.getElementsByName("form");

myDoc.getElementsByName("login");
myDoc.getElementsByName("passwd");
SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorerClass();
IWebBrowserApp wb = (IWebBrowserApp)ie;
wb.Visible = true;
object o = null;
wb.Navigate("yahoomail.com", ref o, ref o, ref o, ref o);
myDoc = wb.Document;
myDoc.forms[0].all("login").value = "prtk@yahoo.com";


}
}




but its not working..give me some code idea

thanks sir


我想你可能想看看这个: http://www.elegancetech.com/CSVB/CSVB.aspx [ ^ ]

试用版将转换1000行代码.
I think you may want to take a look at this: http://www.elegancetech.com/CSVB/CSVB.aspx[^]

the trial version will convert 1000 lines of code.


这篇关于VB到C#的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆