Solved

basic translation from c# to vb.net

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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