?
Solved

Reverse select a textbox

Posted on 2002-04-14
12
Medium Priority
?
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +5
12 Comments
 
LVL 3

Accepted Solution

by:
Bahnass earned 400 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 46

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
 
LVL 46

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 46

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 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