Question:
What is the VB equivalent of this c# code?
Serdar
2012-02-09 16:42:48 UTC
using System;
using System.Data;
using System.Configuration;
using System.Collection;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.Webcontrols;
using System.Web.UI.Webcontrols.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;

namespace DStandard
{
public partial class ErrorPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Title ="Error";
lblNotify.Visible=(Session["SystemError"] != null);

StringReader sr= new StringReader(Request.QueryString["ErrorMsg"].ToString());
string nLine = "";
StringBuilder sb= new StringBuilder();
while ((nLine = sr.ReadLine()) != null)
{
sb.AppendLine(nLine);
}
txtErrorMsg.Text = sb.ToString();
}
}
}
Three answers:
Ratchetr
2012-02-09 17:21:14 UTC
I know C# much better than VB, but this should be close:





Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Title = "Error"



    lblNotify.Visible = Not Session("SystemSomething") Is Nothing



    Dim sr As New StringReader( Request.QueryString("ErrorMessage"))



    Dim nLine As String

    Dim sb As New StringBuilder



    Do

        nLine = sr.ReadLine

        sb.Append(nLine)

    Loop Until nLine Is Nothing



    txtErrorMsg.Text = sb.ToString()

End Sub



You'll need Imports System.IO at the top, in addition to the usual set the MS gives you.



Change SystemSomething and ErrorMessage to the right text, YA! chopped them off.
Daniel B
2012-02-09 16:56:43 UTC
Yahoo Answers chopped some of your code off so I can't give a complete translation, but you can use this site to convert any C# code to VB.NET:



http://www.developerfusion.com/tools/convert/vb-to-csharp/
shemaitis
2016-12-08 14:17:12 UTC
one problem is here: printf("nDo you want to proceed?(y/n): "); scanf("%s",&ch); ch is a single character you're employing %s as a specifier in scanf oops. you need to use %c to test in one character.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...