More Excel Answers
Question Library
Ask a question about Excel
Volunteer
Experts of the Month
Expert Login
Awards
About Us
Tell friends
Link to Us
Disclaimer
|
| |
|
|
| |
| | | |
About Tom Ogilvy
Expertise Worked with the program for many years - provided assistance on MS Excel Newsgroups since 1997. Have received the Microsoft MVP award annually since 1999.
I don't answer questions on using Excel in a browser
Since I have no way to test this. Prefer not to answer charting questions. I consider myself to be particularly knowledgeable about using VBA internal to Excel but have no problems with formulas and pivot tables either.
Experience Have Used Excel for 15 - 20 years. Answered in excess of 70,000 Excel related questions in MS Excel newsgroups. Unless obvious, please specify whether you want a worksheet function or macro/VBA solution.
Education/Credentials BS General Engineering (concentration in Industrial Engineering)
MS Operations Research Systems Analysis
| | |
| |
You are here: Experts > Computing/Technology > Microsoft Software > Excel > vsual basic
Excel - vsual basic
Expert: Tom Ogilvy - 11/7/2009
Question which of the following would place the insertion point in the first position of a text box named txtItem?
txtItem.SelLength=0
txtItem.SelStart=0
txtItem.Text=0
txtItem.Text=1
thanks
Answer Nessie,
I created a userform and with Textbox1 and a commandbutton.
I then put this code in the commandbutton to illustrate
Private Sub CommandButton1_Click()
TextBox1.Value = "The dog is big and fat"
MsgBox TextBox1.SelStart & " " & TextBox1.SelLength
TextBox1.SelStart = 1
TextBox1.SelLength = 0
MsgBox TextBox1.SelStart & " " & TextBox1.SelLength
End Sub
so after it enters the text, the insertion point is a 22.
after the SelStart and SelLength commands are issued, the insertion point is a position 1.
The reason I am providing this is that I am not sure what you are trying to do. If the textbox doesn't have any text in it, the insertion point is in the first position (0). Regardless of where the insertion point is located, if the Textbox doesn't have the focus, you won't see the cursor.
If the textbox has text in it and it doesn't have then focus, then if you click in the box or tab to it, that will change the insertion point.
In general,
txtItem.Text=0
txtItem.Text=1
will put 0 and 1 in the textbox respectively
txtItem.SelLength=0 would allow no text to be selected (just a cursor in the cell)
txtItem.SelStart=0 would place the insertion point in the center.
--
Regards,
Tom Ogilvy
Ask a Question
|
|