How can I convert this piece of VB6 code into C#?
I’ve tried on my own and got so far to:
EDIT: Code I’m trying to translate exists here:
http://www.codeproject.com/KB/vb-interop/MouseHunter.aspx
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You haven’t shown the
EventThiefcode, which makes it impossible to tell, really. But in general:would translate to
(Of course you can specify the type explicitly…)
The commonality here is that
expressionis only evaluated once. In the particular code you showed, there’s no need for an extra variable of course, as the expression is only the local variable in the first place.Your actual error looks like it’s just to do with the types of
EventThief.RIGHT_DOWNetc rather than with the WITH statement.EDIT: Okay, you’ve now shown the original EventThief code which does use Booleans… but you haven’t shown your ported
EventThiefcode. You wrote:… but it shouldn’t be. In the original it’s a
Boolean, so why is it ashortin your port?