ascii code ?

Riangu

Member
Joined
Mar 5, 2007
Messages
8
Programming Experience
Beginner
may i know ascii code 10 and 13 is what?? in vb.net

Thanks... :)
 
Post moved. Don't hijack unrelated topics.

Those ascii values are linebreak characters.
 
Ehm... i'm really sorry.... i really still don't understand how to post and where should i post.... again i'm really sorry... :(

ehm... may i know what is the ascii code for 'enter'??
 
If you search Google et al for "ascii" you will find tables, but why do you need this? There are contants in VB for linefeeds. For example vbNewline constant. If you are checking key input with one of key events there are constants for this too, the Keys enumeration.
 
oh yeah..... rite... thx...
but actually i use e.keycode = keys.enter
i'm not use for newline but i use for something like login when we run beside using click the OK button we can also use press the enter... i forgot that code... so i think to use keyascii code... and i can find any ascii code for 'enter' until now... haha....
again thanks.... :)
 
13 is enter right?? i'm confused by my lecturer... first he said that 13 is enter.. but at last he said that ascii for enter is 10.. so i just want to make sure... but why in coding use 10 can be runable too?? as enter...
 
ASCII code for Enter

It's actually 2 ASCII values: Chr(13) + Chr(10)
in other words - vbCrLf - which is Carriage Return/Line Feed
You can substitute ChrW(Keys.Enter) which is a single Unicode character representing the dual ASCII codes for the Enter key.

For example, the following will return the text in the label for the selected key presses:

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Select Case e.KeyChar
Case " "c
Label1.Text =
"space"
Case ":"c
Label1.Text =
"colon"
Case ChrW(Keys.Enter)
Label1.Text =
"Enter"
End Select
e.Handled = True 'stops beep
End Sub

 
why not just use:
Environment.NewLine (which is self documenting)

and for the enter key simply use: Keys.Enter (which is also self documenting)
?
 
To make a line feed via the chr() function you will have to do it like posted above. For example.
VB.NET:
textbox1.text &= chr(10) & chr(13)
An easier approach would be the Environment Class which was also mentioned above.
VB.NET:
textbox1.text &= Environment.NewLine()
Then you finally have the SendKeys Class in which you can force the keyboard to send the enter key like so
VB.NET:
SendKeys.Send("{ENTER}") or SendKeys.Send("~")
if talking to a different assembly with a UI use
SendKey.SendWait()
If you just want to know the System.Windows.Forms.Form.Keys.Enter Integer value then just look at the intellisense because it tells you.
 
To make a line feed via the chr() function you will have to do it like posted above. For example.
VB.NET:
textbox1.text &= chr(10) & chr(13)
Don't use this; it relies on a VB legacy function (Chr) rather than .NET core (the core equivalent is Convert.ToChar(10) ) and further, it doesnt take account of the system it is running on. 13,10 for CR,LF is a DOS convention only. The UNIX convention is just to use LF, meaning your apps may not be UNIX compliant

An easier approach would be the Environment Class which was also mentioned above.
VB.NET:
textbox1.text &= Environment.NewLine()
Definitely use this. It fixes all the problems, and is not DOS-only


If you just want to know the System.Windows.Forms.Form.Keys.Enter Integer value then just look at the intellisense because it tells you.
Good point sir!

To add to that.. dont forget that you can press F2 and search for Form.Keys to get more info and all the members of the enumeration.. :)

(But note, after lengthy discussion it seems the op was seeking how to tell if enter had been pressed in a key event handler of a textbox, rather than add a newline to a textbox.
 
Back
Top