Solved

basic translation from c# to vb.net

Posted on 2007-03-24
1
272 Views
Last Modified: 2012-06-21
hi

would anyone be able to translate this from c# into vb.net for me. I thought it would be simple but I tried and it didnt work so i must have done something wrong with the event/delegate conversion.

thanks very much in advance
andrea

public class WebUserControl1 : System.Web.UI.UserControl
{
   protected System.Web.UI.WebControls.Button Button1;
   protected System.Web.UI.WebControls.Panel Panel1;

   private void Page_Load(object sender, System.EventArgs e)
   {
      Response.Write("WebUserControl1 :: Page_Load <BR>");
   }

   private void Button1_Click(object sender, System.EventArgs e)
   {
      Response.Write("WebUserControl1 :: Begin Button1_Click <BR>");
      OnBubbleClick(e);
      Response.Write("WebUserControl1 :: End Button1_Click <BR>");
   }

   public event EventHandler BubbleClick;

   protected void OnBubbleClick(EventArgs e)
   {
      if(BubbleClick != null)
      {
         BubbleClick(this, e);
      }
   }          

   #region Web Form Designer generated code
   override protected void OnInit(EventArgs e)
   {
      InitializeComponent();
      base.OnInit(e);
   }
   
   private void InitializeComponent()
   {
      this.Button1.Click += new System.EventHandler(this.Button1_Click);
      this.Load += new System.EventHandler(this.Page_Load);

   }
   #endregion

}
0
Comment
Question by:andieje
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 34

Accepted Solution

by:
Sancler earned 500 total points
ID: 18785574
Try this

Public Class WebUserControl1
Inherits System.Web.UI.UserControl
 Protected Button1 As System.Web.UI.WebControls.Button
 Protected Panel1 As System.Web.UI.WebControls.Panel

 Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
   Response.Write("WebUserControl1 :: Page_Load <BR>")
 End Sub

 Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
   Response.Write("WebUserControl1 :: Begin Button1_Click <BR>")
   OnBubbleClick(e)
   Response.Write("WebUserControl1 :: End Button1_Click <BR>")
 End Sub

 Public Event BubbleClick As EventHandler

 Protected Sub OnBubbleClick(ByVal e As EventArgs)
   RaiseEvent BubbleClick(Me, e)
 End Sub

 Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
   InitializeComponent
   MyBase.OnInit(e)
 End Sub

 Private Sub InitializeComponent()
   AddHandler Me.Button1.Click, AddressOf Me.Button1_Click
   AddHandler Me.Load, AddressOf Me.Page_Load
 End Sub
End Class

I've simply copied and pasted the code "as is" from entering the code you posted into this

http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx

Roger
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question