Re: chr() .Net equivalent

Tech-Archive recommends: Fix windows errors by optimizing your registry



"David Griffiths" <dayvg69@xxxxxxxxxxxxxxxxxx> schrieb
Hi all

I thought I would convert an old program to use just .net, removing
the Microsoft.Visual Basic namespace.

I seem to have succeeded except for just one are. What is the .net
equivalent to chr(). I am capturing the keyboard input and if it's a
carriage return I call the Caluculate Subroutine.

Private Sub txtVat_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtVat.KeyPress If
Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar) Or
e.KeyChar = dp) Then
e.Handled = True
End If

If e.KeyChar = Chr(13) Then
Call Calculate()
End If
End Sub

I have tried replacing the chr(13) with

If e.KeyChar = Environment.NewLine Then
Call Calculate()
End If

No joy. I'm sure there must be a way to do this in .net.

Microsoft.VisualBasic is part of .Net, so you can keep using Chr(). You
can also use vbCr constant. Or Controlchars.CR. Environment.NewLine is
CR+LF, therefore it does not work. You can also use
"Convert.ToChar(13)".

If you want to handle keys not chars, you should handle the KeyDown event.


Armin

.



Relevant Pages

  • chr() .Net equivalent
    ... I thought I would convert an old program to use just .net, removing the Microsoft.Visual Basic namespace. ... Private Sub txtVat_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtVat.KeyPress ...
    (microsoft.public.dotnet.languages.vb)
  • Re: chr() .Net equivalent
    ... I thought I would convert an old program to use just .net, removing the ... Microsoft.Visual Basic namespace. ... Private Sub txtVat_KeyPress(ByVal sender As Object, ... I hope keydown event also meet your purpose. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: chr() .Net equivalent
    ... "David Griffiths" schrieb: ... I take onboard the arguments for keeping the VB namespace and will code accordingly for the future. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: is there a way to change the key of an item within a collection?
    ... "dx" schrieb: ... > string. ... Huh?! ... What doesn't work with removing the item using its old key and ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Override WndProc is stopping shutdown
    ... reason) won't shut down with the application running. ... removing this code, it still does not do the trick. ...
    (microsoft.public.dotnet.framework.windowsforms)