PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Re: chr() .Net equivalent
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
Re: chr() .Net equivalent
![]() |
Re: chr() .Net equivalent |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
"David Griffiths" <dayvg69@yahoo.nospam.co.uk> 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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
"Armin Zingler" <az.nospam@freenet.de> schrieb:
> 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)". I agree, but note that 'Convert.ToChar' is not known by the compiler and thus the conversion is performed at runtime. If you are using 'ChrW' or 'ControlChars.CR' a char literal is stored in the IL. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

