c# -> vb.net

  • Thread starter Thread starter Sam
  • Start date Start date
That's the C# syntax to add an event handler to an event (Validating), which
requires a delegate (CancelEventHandler) which in turn requires a procedure
(cbo_Validating). In VB.NET you can use either:

- the WithEvents clause
- the AddHandler statement with AddressOf function.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
Public Sub cbo_Validating(<...some args...>) Handles cbo.Validating
... do whatever you want...
End Sub

<...some args...> must be the proper signature for the particular event you
are handling (cboValidating, btnClick, txtChange, etc.).
 
The direct equivalent would be (it only makes sense from within a method):
Private Sub test()
AddHandler cbo.Validating, AddressOf cbo_Validating
End Sub

But the alternative that Arthur provided (using "Handles" & "WithEvents") is
more in the style of VB.

David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top