Re: chr() .Net equivalent
- From: "Armin Zingler" <az.nospam@xxxxxxxxxx>
- Date: Sun, 30 Mar 2008 18:00:20 +0200
"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
.
- Follow-Ups:
- Re: chr() .Net equivalent
- From: Herfried K. Wagner [MVP]
- Re: chr() .Net equivalent
- References:
- chr() .Net equivalent
- From: David Griffiths
- chr() .Net equivalent
- Prev by Date: chr() .Net equivalent
- Next by Date: Re: DotNet equivlant of vb 6 instr
- Previous by thread: chr() .Net equivalent
- Next by thread: Re: chr() .Net equivalent
- Index(es):
Relevant Pages
|