简体   繁体   中英

How should I convert the following C# statement to vb.net?

I have the following statement which I am trying to convert to vb.net. The assembly referenced was written in C# too.

The C# code is

  this.calendar1.DayHeaderClick += New System.Windows.Forms.Calendar.Calendar.CalendarDayEventHandler(this.calendar1_DayHeaderClick)

and I tried to write it as in vb.net

 AddHandler this.calendar1.LoadItems, New EventHandler(AddressOf this.calendar1_LoadItems)

and

AddHandler this.calendar1.LoadItems, New EventHandler(System.Windows.Forms.Calendar.calendarl(this.calendar1_LoadItems))

I keep getting one or the other. One among them was this .

I am new to vb.net.

Thanks in advance.

C#使用this引用形式,而VB使用Me

AddHandler Me.calendar1.LoadItems, AddressOf Me.calendar1_LoadItems

I would try to choose the calendar1 in the codebehind window and then under declarations choose DayHeaderClick to let Visual studio generate the code.

You then get VB code that looks like :

 Private Sub MonthCalendar1_KeyDown(sender As Object, e As KeyEventArgs) Handles MonthCalendar1.KeyDown

 End Sub

Observe that I dont have acces to your Calendar-control so above is just an example.

Now I tried my own reccomendation and I got:

Imports System.Windows.Forms.Calendar

Private Sub Calendar1_DayHeaderClick(sender As Object, e As CalendarDayEventArgs) Handles Calendar1.DayHeaderClick

End Sub

Use the following website. It is pretty good:

http://www.developerfusion.com/tools/convert/csharp-to-vb/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM