Jumping to the next line in VB code
okay, simple question. How in visual basic code do you tell the prompt to go to the next line in the same control on a form? In other words, how do you mimic the behavior of the enter key in code?
You can change the behavior of the Enter key on the "Other" tab of the properties sheet for the control or just hold down the <Ctrl> key while using the Enter hey.
July 10th, 2006, 10:26 AM
Thanks. However, how do you write that function in code?
July 10th, 2006, 10:42 AM
I'm not sure I understand!! Do you want to insert an "Enter" character in a control such as a textbox?? If so, try the vbCrLf (Carriage Return Line Feed) character:
Text1.Text = "This is one line" & vbCrLf & "and this is on the next"
July 10th, 2006, 10:52 AM
Sorry, that wasn't what you wanted, to do what RuralGuy syggested using code you just have to put the following in the Forms Load event:
changing text4 to the name of your control
Text4.EnterKeyBehavior = True
July 10th, 2006, 03:22 PM
hehe, thanks... however, that's not what i was intending to ask. Sorry about that. Let me put it another way. How do you insert text into a control? Say there are 3 controls in which a user inputs data and I want one textbox to display all 3 of these controls. I want it so that each time one of these controls is filled out by the user, the textbox automatically updates and displays the data.
So, for examples:
Control 1: 1, Control 2: <blank>, Control 3: <blank>
Control 1: 1, Control 2: 2, Control 3: <blank>
Control 1: 1, Control 2: 2, Control 3: 3
Please notice how the controls are all listed on different lines in the textbox. How would I do/code this? I've already established in the AfterUpdate event of the controls: Me!Textbox = Me!Control1 & " " & Me!Control2 & " " & Me!Control3
But, that doesn't give me the formatting I'm looking for. Thanks to anyone who can/try to answer this!
July 10th, 2006, 03:39 PM
Sync or Swim supplied the answer in his/her 1st post.
Me!Textbox = Me!Control1 & vbCrLf & Me!Control2 & vbCrLf & Me!Control3
July 10th, 2006, 04:56 PM
AHHH DUH! Sorry, overlooked. Feel like an idiot. Thanks a lot!!! =)