Please convert to VB.NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please convert to VB.NET

protected override bool ProcessKeyEventArgs(ref Message m)
{

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

m.WParam = (IntPtr)',';

return false;

}

Thanks!
Buzz
 
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#
 
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."
 
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#
 
Hi David,

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

Thanks,
Buzz
 
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
 
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
 
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,

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
 
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#
 
Back
Top