Coverting VB into C#

Can anyone recommend some free tools on how convert VB into C#?  I tried using:
http://www.developerfusion.com/tools/convert/vb-to-csharp/
but I get an error that:

    * protected void // ERROR: Handles clauses are not supported in C# rbl1_SelectedIndexChanged(object sender, System.EventArgs e)
    * {
    *    
    *     if (rblAns.SelectedValue == "status_guest") {
    *         RequiredFieldValidator4.enabled = true;
    *     }
    *     else {
    *         RequiredFieldValidator4.enabled = false;
    *     }
    *    
    * }


<SCRIPT LANGUAGE="VBScript"> 
//Give users the option to enter school information
         
  Protected Sub rbl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbl1.SelectedIndexChanged
     
  If rblAns.SelectedValue = "status_guest" Then
      RequiredFieldValidator4.enabled = True
  else
      RequiredFieldValidator4.enabled = False
  End If
 
End Sub
 
 
 </script>

Open in new window

jianxin9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Daniel JungesCommented:
you can use SharpDevelop, it is free
http://www.icsharpcode.net/OpenSource/SD/
0
jandromedaCommented:
I'm not sure there is any too which converts the 'Handles' clause to the C#. But you can fix this without the help of a tool. Try this code.
protected void rbl1_SelectedIndexChanged(object sender, System.EventArgs e)
{
   
   if (rblAns.SelectedValue == "status_guest") {
        RequiredFieldValidator4.enabled = true;
   }
    else {
         RequiredFieldValidator4.enabled = false;
   }
    
 }
 
// and at the place where you declared and initialized the rbl1 add this code.
 <asp:RadioButtonList id="rbl1" 
            OnSelectedIndexChanged="rbl1_SelectedIndexChanged"
            AutoPostBack="true"
            runat="server"/>

Open in new window

0
jianxin9Author Commented:
Thanks for posting!  Okay, when I try this I am getting a runtime error. I have posted the code I am using below.  Thanks!

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>
<script runat="server" language="C#">
protected void status_SelectedIndexChanged(object sender, System.EventArgs e)
{
   
   if (rblAns.SelectedValue == "status_guest") {
        RequiredFieldValidator4.enabled = true;
   }
    else {
         RequiredFieldValidator4.enabled = false;
   }
    
 }
 
 
 
 </script>
 
 
 
RADIO BUTTON LIST:
Status:*<br /><asp:RadioButtonList id="status" 
            OnSelectedIndexChanged="status_SelectedIndexChanged"
            AutoPostBack="true"
            runat="server"/>
 
                                <asp:ListItem id="status_undergrad" runat="server" Value="undergraduate" />
                                <asp:ListItem id="status_grad" runat="server" Value="graduate" />
                                <asp:ListItem id="status_fs" runat="server" Value="faculty or staff" />
                                 <asp:ListItem id="status_guest" runat="server" Value="guest user (non)" /></asp:RadioButtonList>   
 
                                                                                                 <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="status"
                            ErrorMessage="Status" runat="Server" Text="*Status Required"></asp:RequiredFieldValidator><br />
                                                                                                                If you are a guest user, <br /> please tell us what school are you from:<asp:TextBox ID="school" runat="server"></asp:TextBox>
 <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="school"
                            ErrorMessage="School Name" runat="Server" Text="*School Name Required"></asp:RequiredFieldValidator>
           
        <br />

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jandromedaCommented:
This is firing because it cannot capture another error. So as the first step add this to the web.config of your application. If you already have a '<system.web>' element add the '<customErrors mode = "Off"/>' into that.

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>
0
jianxin9Author Commented:
Hi, thanks for posting.  I do currently have this in my web.config and I'm still getting the error.  I am going to post all my code behind--I don't expect you to go through it all, of course, but maybe something might stand out?


<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>
<%@ Page Language="c#" Debug="true" %>
 
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Net" %>
 
<script runat="server" language="C#">
		 
 
 
  void Page_Load()
  {
      if (Page.IsPostBack)
      {
          questionsPanel.Visible = false;
          Message.Visible = true;  
          int correct = 0;
          if (q1.SelectedIndex == 2) correct++;
          if (q2.SelectedIndex == 4) correct++;
          if (q3.SelectedIndex == 2) correct++;
          if (q4.SelectedIndex == 0) correct++;
          if (q5.SelectedIndex == 5) correct++;
          if (q6.SelectedIndex == 1) correct++;
          if (q7.SelectedIndex == 2) correct++;
 
          LoadConn(correct);
      }
      else
      {
          questionsPanel.Visible = true;
          Message.Visible = false;  
      }
  }
 
private void LoadConn(int score)
{
    int percent;
    percent = (score*100)/7;  
  
    // Create the objects 
    OleDbConnection conn;
    OleDbCommand comm;
    
    // Instance the connection open it
    conn = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source ="+ Server.MapPath("assessments.accdb")+";User Id=Admin; Jet OLEDB:Database Password=Live4Ever;");
    conn.Open();
    
    // Create the insert SQL 
    string sSQL = "";
		string qname = "plagiarism"; 
    sSQL = "Insert into posttest_table(fname,lname,username,coursenum,emailId,emailId2,status,school,qname,answered,score,q1,q2,q3,q4,q5,q6,q7) values('" + fname.Text + "','" + lname.Text +"','" + portal_id.Text +"','"+course_id.Text+"','"+emailId.Text+"','"+emailId2.Text+"','"+(status.SelectedIndex+1)+"','"+ school.Text +"','"+(qname)+"',"+score+","+percent+","+(q1.SelectedIndex+1)+","+(q2.SelectedIndex+1)+","+(q3.SelectedIndex+1)+","+(q4.SelectedIndex+1)+","+(q5.SelectedIndex+1)+","+(q6.SelectedIndex+1)+","+(q7.SelectedIndex+1)+");";
   
    //  Response.Write(sSQL + "<br />");
    //  Response.End();
    //  return;
    
    // Create a command object from the connection
    comm = conn.CreateCommand ();
    comm.CommandText = sSQL;
    comm.CommandType = CommandType.Text;
 
    // Try the insert 
    try
    {
        comm.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        Response.Write("Error During DB Update: " + ex.ToString());
    }
    
    
   
    conn.Close();
    // Inserting data into the database end
     
    // Create the email body text
/* String bodyInfo = fname.Text+" "+lname.Text+" has taken the exam.\n <br />"+fname.Text  +" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option 3)<br /> You Answered:  Option "+(q1.SelectedIndex+1)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option 5) <br />You Answered: Option "+(q2.SelectedIndex+1)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option 3) <br />You Answered: Option "+(q3.SelectedIndex+1)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option 1) <br />You Answered: Option "+(q4.SelectedIndex+1)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option 6) <br />You Answered: Option "+(q5.SelectedIndex+1)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option 2) <br />You Answered: Option "+(q6.SelectedIndex+1)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option 3) <br /> You Answered: Option "+(q7.SelectedIndex+1);*/
 
 String bodyInfo = fname.Text+" "+lname.Text+" is a/an "+status.Text+", and has taken the exam for the course "+course_id.Text+".\n <br />"+fname.Text+" has scored: "+percent+" out of 100 and gotten "+score+" out of 7 questions correct.\n<br /><br />"+fname.Text  +"'s options were: \n<br /> Question 1. Plagiarism is the act of: <br />The correct answer is: using someone else's work and not giving them credit (Option c)<br /> You Answered:  Option "+Convert.ToChar(q1.SelectedIndex+97)+"\n <br /><br />Question 2.  Which of the following is copyrighted infringement? <br />The correct answer is: all of the above (Option e) <br />You Answered: Option "+Convert.ToChar(q2.SelectedIndex+97)+"\n <br /><br />Question 3.  Accidental plagiarism is: <br />The correct answer is: always unacceptable (Option c) <br />You Answered: Option "+Convert.ToChar(q3.SelectedIndex+97)+"\n <br /><br />Question 4. When citing my resources it is important that I: <br />The correct answer is: use a standard citation format assigned by your professor (Option a) <br />You Answered: Option "+Convert.ToChar(q4.SelectedIndex+97)+"\n <br /><br />Question 5. RefWorks can help you: <br />The correct answer is: a, c, d (Option f) <br />You Answered: Option "+Convert.ToChar(q5.SelectedIndex+97)+"\n<br /><br /> Question 6. Which of the following best describes plagiarism?  <br />The correct answer is: It's a serious offense and can result in severe penalties (Option b) <br />You Answered: Option "+Convert.ToChar(q6.SelectedIndex+97)+"\n<br /><br /> Question 7. When do you have to cite your resources? <br /> The correct answer is: when what you are writing about is someone else's idea (Option c) <br /> You Answered: Option "+Convert.ToChar(q7.SelectedIndex+97);
 
 
    // Create SMTP client
    SmtpClient client = new SmtpClient("mail.twu.edu");
        
    // Create SMTP message
    MailMessage message = new MailMessage();
 
    // Set message properties 
    message.From = new MailAddress ("automailer@twu.edu");
    message.To.Add("tutorial-results@mail.twu.edu");
    message.CC.Add(emailId.Text);
   if (!string.IsNullOrEmpty(emailId2.Text))
    {
       message.CC.Add(emailId2.Text);
    }
    message.Body = bodyInfo;
    message.Subject = "Doing Research: Plagiarism Quiz Results";
    message.IsBodyHtml = true;
   
    try
        {
 
            // Send EMail
            client.Send(message);
        }
        catch (Exception ex)
        {
            // Do Nothing  
        }
				
 
    // Send the user to the Results page
    Response.Redirect("results.aspx?fname="+fname.Text+"&lname="+lname.Text+"&score="+percent+"&q1="+(q1.SelectedIndex)+"&q2="+(q2.SelectedIndex)+"&q3="+(q3.SelectedIndex)+"&q4="+(q4.SelectedIndex)+"&q5="+(q5.SelectedIndex)+"&q6="+(q6.SelectedIndex)+"&q7="+(q7.SelectedIndex));
 
}
 
protected void status_SelectedIndexChanged(object sender, System.EventArgs e)
{
   
   if (rblAns.SelectedValue == "status_guest") {
        RequiredFieldValidator4.enabled = true;
   }
    else {
         RequiredFieldValidator4.enabled = false;
   }
    
 }
 
 
 
 </script>
 
   

Open in new window

0
jandromedaCommented:
Modify the Page directive as given below.

<%@ Page Language="c#" Debug="true" AutoEventWireup="true" %>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jianxin9Author Commented:
THanks for responding.  Ugh--I am getting the same error.  

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>
0
CyrexCore2kCommented:
jian do you have a database that you can access?

I always have trouble getting errors to show up in the browser so I've basically given up on it. However, you can add the Global.asax file to your project and in it's code behind under the Application_Error event just have it save the last error to the database. From there you can just read what the error is in the database.

Here's an example:

       
protected void Application_Error(object sender, EventArgs e)
{
   Exception ex = Server.GetLastError().GetBaseException();
 
   // Connect to database and save ex.ToString() to it. 
            
}

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.