Solved

basic translation from c# to vb.net

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

930 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now