471,338 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Please convert to VB.NET

Please convert to VB.NET

protected override bool ProcessKeyEventArgs(ref Message m)
{

if((char)m.WParam == '.')

m.WParam = (IntPtr)',';

return false;

}

Thanks!
Buzz
Aug 19 '05 #1
10 2356
Our Instant VB C# to VB converter produces the following (download the demo
edition at www.instantvb.com)

Protected Overrides Function ProcessKeyEventArgs(ByRef m As Message) As
Boolean

If CChar(m.WParam) = "."c Then
m.WParam = CType(","c, IntPtr)
End If

Return False

End Function

--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Clear VB: Cleans up outdated VB.NET code
Instant C#: Converts from VB.NET to C#
Instant VB: Converts from C# to VB.NET
Instant J#: Converts from VB.NET to J#
"Buzz" wrote:
Please convert to VB.NET

protected override bool ProcessKeyEventArgs(ref Message m)
{

if((char)m.WParam == '.')

m.WParam = (IntPtr)',';

return false;

}

Thanks!
Buzz

Aug 20 '05 #2
Hi Buzz,

Please try the following VB.NET code.

Protected Overrides Function ProcessKeyEventArgs(ByRef m As Message) As
Boolean
If Convert.ToChar(m.WParam.ToInt32()) = "."c Then
m.WParam = New IntPtr(Convert.ToInt32(","c))
Return False
End If
End Function

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Aug 20 '05 #3
David,

Which is in my opinion very nice real VB.Net code

:-)

Cor
Aug 20 '05 #4
By the way, if this isn't just an adhoc sample, you might want to review what
it's supposed to do - it always returns false for instance. Also, there's no
need for the parameter to be 'ref'.
--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Clear VB: Cleans up outdated VB.NET code
Instant C#: Converts from VB.NET to C#
Instant VB: Converts from C# to VB.NET
Instant J#: Converts from VB.NET to J#
"Buzz" wrote:
Please convert to VB.NET

protected override bool ProcessKeyEventArgs(ref Message m)
{

if((char)m.WParam == '.')

m.WParam = (IntPtr)',';

return false;

}

Thanks!
Buzz

Aug 20 '05 #5
Hi David,

Kevin Yu's VB.NET example worked. I was unable to get your example working.

Thanks,
Buzz

"David Anton" wrote:
By the way, if this isn't just an adhoc sample, you might want to review what
it's supposed to do - it always returns false for instance. Also, there's no
need for the parameter to be 'ref'.
--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Clear VB: Cleans up outdated VB.NET code
Instant C#: Converts from VB.NET to C#
Instant VB: Converts from C# to VB.NET
Instant J#: Converts from VB.NET to J#
"Buzz" wrote:
Please convert to VB.NET

protected override bool ProcessKeyEventArgs(ref Message m)
{

if((char)m.WParam == '.')

m.WParam = (IntPtr)',';

return false;

}

Thanks!
Buzz

Aug 22 '05 #6
Buzz,
Kevin Yu's VB.NET example worked. I was unable to get your example
working.


I can oversee something however looking at David's code is it the same as
from Kevin (who uses only the basic framework), while in Buzz code are some
more optimized VBNet methods used.

Probably I oversee something however when not than it can be interesting and
therefore: Can you give us the error you got with Buzz his code?

Cor
Aug 22 '05 #7
If CChar(m.WParam) = "." Then 'Value of type 'System.IntPtr' cannot be
converted to 'Char'.
m.WParam = CType(",", IntPtr) 'Value of type 'String' cannot be
converted to 'System.IntPtr'.
End If
"Cor Ligthert [MVP]" wrote:
Buzz,
Kevin Yu's VB.NET example worked. I was unable to get your example
working.


I can oversee something however looking at David's code is it the same as
from Kevin (who uses only the basic framework), while in Buzz code are some
more optimized VBNet methods used.

Probably I oversee something however when not than it can be interesting and
therefore: Can you give us the error you got with Buzz his code?

Cor

Aug 22 '05 #8
Thanks for the bug report Buzz. We're looking into it now - it appears that
the intrinsic VB cast methods do not cut it (compared to C# casting) in many
cases.
Within the next day we'll have a new build that results in conversions
making more use of the Convert class methods.
--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Clear VB: Cleans up outdated VB.NET code
Instant C#: Converts from VB.NET to C#
Instant VB: Converts from C# to VB.NET
Instant J#: Converts from VB.NET to J#
"Buzz" wrote:
If CChar(m.WParam) = "." Then 'Value of type 'System.IntPtr' cannot be
converted to 'Char'.
m.WParam = CType(",", IntPtr) 'Value of type 'String' cannot be
converted to 'System.IntPtr'.
End If
"Cor Ligthert [MVP]" wrote:
Buzz,
Kevin Yu's VB.NET example worked. I was unable to get your example
working.


I can oversee something however looking at David's code is it the same as
from Kevin (who uses only the basic framework), while in Buzz code are some
more optimized VBNet methods used.

Probably I oversee something however when not than it can be interesting and
therefore: Can you give us the error you got with Buzz his code?

Cor

Aug 22 '05 #9
Buzz,

Thanks for showing it.

It would be in the shortest code

ChrW(m.WParam.ToInt32)
and
New IntPtr(Asc(","))

Before you misunderstand me, there is nothing wrong with the code from
Kevin. I have now learned again from this.

Thanks

Cor
Aug 22 '05 #10
Thanks Cor - we've modified Instant VB to include this correction (and the
VB-ish style of using AscW and ChrW) for casts of InPtr's to characters and
characters to IntPtr's. (Download the demo at www.instantvb.com if you're
interested in trying it out).
--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Clear VB: Cleans up outdated VB.NET code
Instant C#: Converts from VB.NET to C#
Instant VB: Converts from C# to VB.NET
Instant J#: Converts from VB.NET to J#
"Cor Ligthert [MVP]" wrote:
Buzz,

Thanks for showing it.

It would be in the shortest code

ChrW(m.WParam.ToInt32)
and
New IntPtr(Asc(","))

Before you misunderstand me, there is nothing wrong with the code from
Kevin. I have now learned again from this.

Thanks

Cor

Aug 22 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Karunakararao | last post: by
10 posts views Thread by Buzz | last post: by
3 posts views Thread by Todd_Goselin | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.