Dear Sir
I 'm trying convert c# to vb.net but I have an error : `Error BC30311 Value of type 'Keys' cannot be converted to 'Char'.` in vb.net
Please Guide me.
Thanks
Code in c#
public override bool KeyEntersEditMode(KeyEventArgs e)
{
NumberFormatInfo numberFormatInfo = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
Keys negativeSignKey = Keys.None;
string negativeSignStr = numberFormatInfo.NegativeSign;
if (!string.IsNullOrEmpty(negativeSignStr) && negativeSignStr.Length == 1)
{
negativeSignKey = (Keys)(VkKeyScan(negativeSignStr[0]));
}
if ((char.IsDigit((char)e.KeyCode) ||
(e.KeyCode >= Keys.NumPad0 && e.KeyCode <= Keys.NumPad9) ||
negativeSignKey == e.KeyCode ||
Keys.Subtract == e.KeyCode) &&
!e.Shift && !e.Alt && !e.Control)
{
return true;
}
return false;
}
Code in vb.net
Public Overrides Function KeyEntersEditMode(ByVal e As KeyEventArgs) As Boolean
Dim numberFormatInfo As NumberFormatInfo = System.Globalization.CultureInfo.CurrentCulture.NumberFormat
Dim negativeSignKey As Keys = Keys.None
Dim negativeSignStr As String = numberFormatInfo.NegativeSign
If Not String.IsNullOrEmpty(negativeSignStr) AndAlso negativeSignStr.Length = 1 Then
negativeSignKey = CType(VkKeyScan(negativeSignStr.Chars(0)), Keys)
End If
`Error below line code
If (Char.IsDigit(CChar(e.KeyCode)) OrElse (e.KeyCode >= Keys.NumPad0 AndAlso e.KeyCode <= Keys.NumPad9) OrElse negativeSignKey = e.KeyCode OrElse Keys.Subtract = e.KeyCode) AndAlso Not e.Shift AndAlso Not e.Alt AndAlso Not e.Control Then
Return True
End If
Return False
End Function