English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Im a yr 12 student doing an assignment on VB. I have a text box for people to type things into and then they click on a command button to save it as a variable. What do i need to do to save it when they press enter instead of haveing to click the command button? Something to do with ASCCI enter?

2007-03-14 22:15:25 · 3 answers · asked by B-rad 3 in Computers & Internet Programming & Design

3 answers

You can do it with ASCII... in KeyDown Event of Textbox
here's simple sample for you...

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then MsgBox "Enter"
End Sub

Or you can do it with Command Button.

first, create command button and in the property-pane, you can easily find the property of Command_Button.

if you turn it on(true), then while typing in the textbox
when you press the enter, then that command_button takes the event.

here's another one...

Private Sub Command1_Click()
MsgBox Text1.Text
End Sub

(here, above all,you should turn on the property of button, then finally F5...)

Good Luck...

2007-03-14 22:37:58 · answer #1 · answered by QuizBox 2 · 0 0

One the main page, click the background. In the "Properties", Under "Misc", select "AcceptButton", select the button that corresponds to that "Enter" button

2007-03-15 18:32:52 · answer #2 · answered by Anonymous · 0 0

Well you need to do little bit of research on ASCII. find out the value of ASCII of enter key and thats it.

on form keypress event try this

msgbox ascii

and u will get it through it

it may be

msgbox keyascii

write that without quotes otherwise u wont get value of it

2007-03-15 05:31:41 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers