Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert c# routine to vb

Status
Not open for further replies.

chadau

Programmer
Nov 14, 2002
155
US
Code:
public void Init(HttpApplication app)
        {
            // Register for pipeline events
            app.AcquireRequestState += new EventHandler(this.OnAcquireRequestState);
        }
 
Something like this.

public sub Init(byval app as HttpApplication)

' Register for pipeline events
AddHandler app.AcquireRequestState, AddressOf OnAcquireRequestState

end sub
 
Just a word of warning that translators don't produce 100% accuracy and I tend to stay well away from them.

This is proven in this case as adding handlers in C# is completely different to adding handlers in VB.NET and the code that is generated from that translator will not work!

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
True, but at least it is a place to start. I am not offering a cut and paste solution, but is a beginning point for those of us who don't know C# . I use this page all the time!
 
You may use the page all the time but that doesn't mean it works and in this case you offered a solution that simply said "go here and paste your code". For anyone who doesn't know VB.NET they may have just followed your advise and ended up with the following code that is not a valid solution:
Code:
app.AcquireRequestState += New EventHandler(Me.OnAcquireRequestState)
What should have been used is the VB.NET method of adding handlers (correctly identified by stsuing) which was:
Code:
AddHandler app.AcquireRequestState, AddressOf OnAcquireRequestState

I agree that it may be a useful starting point for some situations but not in this case.


--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
This book is 5 bucks used and will make you a better programmer. Even if you only plan on doing VB you should read this. It's only 150 pages.
"C# & VB.NET Conversion Pocket Reference" by Jose Mojica

I use the translators all the time, but didn't give that advise because I was burned on the handlers and other syntax that is uncorrectly translated.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top