473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

chr() .Net equivalent

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.

Help please. Thanks in advance

--
DaveG

Mar 30 '08 #1
4 3436
"David Griffiths" <da*****@yahoo.nospam.co.ukschrieb
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

Mar 30 '08 #2
"Armin Zingler" <az*******@freenet.deschrieb:
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/>

Mar 30 '08 #3
Thanks for all the input.

I managed to complete the project removing "VB namespace" I went with the
Convert.ToChar() solution.

I take onboard the arguments for keeping the VB namespace and will code
accordingly for the future.

--
DaveG

"David Griffiths" <da*****@yahoo.nospam.co.ukwrote in message
news:Qt*********************@telenor.com...
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.

Help please. Thanks in advance

--
DaveG
Mar 31 '08 #4
Hi Dave,

I tend to avoid the VB helper routines, but in this case I definitely favor
ChrW() as it is in fact compiled as a contant
"David Griffiths" <da*****@yahoo.nospam.co.ukwrote in message
news:YJ*********************@telenor.com...
Thanks for all the input.

I managed to complete the project removing "VB namespace" I went with the
Convert.ToChar() solution.

I take onboard the arguments for keeping the VB namespace and will code
accordingly for the future.

--
DaveG

"David Griffiths" <da*****@yahoo.nospam.co.ukwrote in message
news:Qt*********************@telenor.com...
>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.

Help please. Thanks in advance

--
DaveG
Mar 31 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Eddie B. | last post by:
Does anyone know how to do Chr$(13) in .NET? Thanks, Eddie
6
by: Vasanth | last post by:
Hi Techies, Could you please let me know the equivalent of VB.Net chr() in C#.net? Regards, Vasanth
3
by: charliewest | last post by:
Can anyone tell me what the C# equivalent of the VB Chr() Function? I need to insert a single-byte character into a label control at run time. For example: Dim s = "Hello" + Chr(32)
3
by: Alberto | last post by:
In a application in visual basic 6 I had chr$(13). How can I get the same value in C#? Thank you
9
by: INeedADip | last post by:
'Asc' returns an Integer value representing the character code corresponding to a character 'Chr' is the inverse and returns the character associated with the specified character code What...
1
by: sakina | last post by:
I am trying to change some code from VB to C#. I have a variable called pstrHex with a value of "49799879A7E109F3B4BB4224257E50B5" in VB, the following code: HexToString = HexToString &...
5
by: Christian Blackburn | last post by:
Hi Gang, I would like to use a caesar cipher on the mailto: links in my website to prevent crawlers from farming the e-mails off my site. Can someone tell me the equivalents to Chr() and Asc()...
0
by: basudahal | last post by:
I am trying to convert from VB to C#. Could you help me with Chr$(&HD) or Chr$(&HA) equivalent to C#? I would really appreciate.
7
by: Zytan | last post by:
I am trying to set a const string made up of Chr(), but if the value passed into Chr() is too large, the compiler complains that it is not constant!! Example: Public Const m_Data As String =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.