Solved

Reverse select a textbox

Posted on 2002-04-14
12
331 Views
Last Modified: 2012-06-22
Hey,

I have a single line text box. I would like to select the text in the text box so that when that text box receives focus, the text would be selected from right to left instead of left to right. Left to right selection if provided by :

txtBox1.SelStart = 0
txtBox1.SelLength = Len(txtBox1.Text)
0
Comment
Question by:dhwanilshah
  • 3
  • 2
  • 2
  • +5
12 Comments
 
LVL 3

Accepted Solution

by:
Bahnass earned 100 total points
ID: 6939956
Sorry Don't understand U???
lines U wrote are selecting the hole textbox area (So no write or left)

no of char in text box is given by Len(txtBox1.Text)

if U want to select first 2 char
txtBox1.SelStart = 0
txtBox1.SelLength = 2

if U want last 2 char
txtBox1.SelStart = Len(txtBox1.Text)-2
txtBox1.SelLength = 2

textbox has righttoleft property to display contents in that order

Hope that helps!!!!!!    thaugh I don't understand Q!!

0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6939961
in VB 6, you can change the RightToLeft property of the text box to TRUE, then text will be entered into the text box from Right To Left, (the default is Left to Right).  Is that what you are asking?
0
 
LVL 3

Expert Comment

by:jbil
ID: 6939987
one way....

Private Sub Text1_GotFocus()
Text1.SelStart = Len(Text1)
SendKeys "+{HOME}"
End Sub
0
 
LVL 45

Expert Comment

by:aikimark
ID: 6940010
What are you trying to accomplish with this?  If all the text is selected, what difference does it make if it is selected from left-to-right or right-to-left?

jbil seems to have workable solution.  In a production environment, I would look at using the SendMessage API instead of SendKeys if feasable.
0
 
LVL 5

Expert Comment

by:kcm76
ID: 6940296
I dont see any difference for a text selecting in what so ever order. btw, when a text is selected in a textbox, and if the text box loses the focus, the selection is also gone.

*****the text would be selected from right to left instead of left to right*****

What does it mean? could u Pls post some more info.

KCM
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6943028
Just observing...
Try this experiment and you'll understand the question:

Click on [Start]|Run...

In the run combobox if you don't have something selected, enter Notepad, click OK, then repeat until something is selected.

Look carefully at the selected text and notice that the cursor is at the END of the selected text.  Press the left arrow key and notice that the cursor ends up to the left of the last character.

Now press the following key sequence: END, SHIFT+HOME

Notice that everything is highlighted, but the cursor is now blinking at the beginning.  Try cursor left again and notice that the cursor ends up at the beginning of the text.

Similarly, using shift-cursor will give different results.

--
Why do you need this?  Convenience for some things, but ultimately I'd say that since no other applications do it, there's a good chance that this convenience will simply confuse many users and may not be worth the effort.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 45

Expert Comment

by:aikimark
ID: 6943471
Having your application automatically select the text is meant to be a convenience for the user to not have to delete text before typing completely new text.  

If the user wants to append new text, they must one of the following:
* press the End key
* press the right arrow key
* click to the right of the text with the mouse

If the user wants to prepend new text, they must one of the following:
* press the Home key
* click to the left of the text with the mouse
(Yes they can hold the left arrow key until the cursor reaches the start of the text, but the Home key is simpler and quicker.)

Without further information from you, we experts are at a loss to do anything other than advise you to avoid non-Windows-standard behavior.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7654057
Hi dhwanilshah,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Arthur_Wood@devx's comment(s) as an answer.

dhwanilshah, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 45

Expert Comment

by:aikimark
ID: 7655263
DanRollins,

I disagree with your recommendation.  Bahnass mentioned the righttoleft textbox property before Arthur_Wood (by four minutes).
0
 
LVL 3

Expert Comment

by:Bahnass
ID: 7655604
Thank aikimark
    any How My comment was to help asker who is not there even to say thanks!!

Thanks all EE's    
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7659767
Thanks for the input.  I'm changing my recommendation to:

  Accept Bahnass's comment(s) as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7755045
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now