Solved

basic translation from c# to vb.net

Posted on 2007-03-24
1
264 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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Zoom web page in asp.net 2 34
Visual Studio installation 5 32
.net VBA word safemode 1 23
Expando 4 33
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…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

11 Experts available now in Live!

Get 1:1 Help Now