Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a Button Default and Text box

Status
Not open for further replies.

azamatali

Programmer
Joined
Aug 20, 2001
Messages
50
Location
IN
hi folks.
I have made a form and set a button to deafault(i.e. when the enter button will be pushed the button is pressed)
But it is giving problem.. on the same form i am having a multiline text box.. now whenever i press enter to go to the next line in the text box.. This enter is taken by the button and the button push event occurs.
Now how can i make the button default enter and still press enter in the text box..
Please guide me..
Thanks..
 
Try this
Text1 = your multiline text box
Command1 = your default button

Private Sub Command1_Click()
Dim oCtrl As Control

Set oCtrl = ActiveControl

If oCtrl = Text1 Then
Text1.SelText = vbCrLf
Exit Sub
End If

MsgBox "Default button clicked"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top