Solved

basic translation from c# to vb.net

Posted on 2007-03-24
1
266 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

825 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