SelStart = The beggining of SelText
I Have an RTB and i have selected text i.e.
Seltext="DFGHJKIHLKJLKJ"
I want the cursor to go back to the begging of the seltext and leave the text selected.
So in other words Select "DFGHJKIHLKJLKJ" and move the cursor back in front of the "D".
This seltext can be anywhere in the richtextbox so it is variable.
THanks for the HELP! :D
Re: SelStart = The beggining of SelText
Why not try Len() and Left$()?! It's something like :
Text1.text being a string
If Len(Text1.Text) = 14 Then
Text1.Text = Left$(Text1.Text, 1) & Text1.Text
End If
I never tried these code, but this might help to get you started...
Re: SelStart = The beggining of SelText
Two things 1) this is over 16 years old. If they haven't gotten their answer by now, they'll never get it. 2) your code still doesn't do what was asked.
-tg
Re: SelStart = The beggining of SelText
Re: SelStart = The beggining of SelText
I tried this:
Code:
rtb.Text = "Mary had a little lamb"
i = InStr(rtb.Text, "little")
rtb.SelStart = i - 1
rtb.SelLength = 6
Debug.Print rtb.SelStart & " " & rtb.SelText
Debug printed 11 little is that what you're looking for?
Re: SelStart = The beggining of SelText
K---
Did you even READ posts 19 & 20?
Re: SelStart = The beggining of SelText
Yes, as a matter of fact I did. Why do you ask?
Re: SelStart = The beggining of SelText
Because you're replying to a person who asked the question sixteen years back and hasn't been active on the forum for about four years. The odds that they are still interested in the question are pretty slim. The odds that they are still using the language aren't that good, either. And finally, the answer you gave seems to miss the point of the question. Selecting part of the text is easy. Selecting part of the text, leaving it selected, AND putting the cursor elsewhere is what wasn't so easy.
Re: SelStart = The beggining of SelText
Needless to say, I disagree with all points. First, as this board apparently has no Statute of Limitations, a fourteen year old threads remain active, it did/does not seem out of line to post a reply. Quite possibly the message originator has fallen from his perch a long time ago, but as evidenced by your responses, the posting has not gone unread (the object of the exercise). Lastly, the original message is explicit and states the selStart is to be moved to the front of the selText. Not at some unspecified position.
Notwithstanding the above, I bow to the censure of a 'super moderator',
Bob.
Re: SelStart = The beggining of SelText
True, there is no expiration on an open thread. However, there is an expiration on the utility of an answer to an open thread, and there is one, possible, side effect to replying to such an ancient thread. Frankly, I kind of think it might be beneficial, so I'm pretty ambivalent about it. The side effect is due to the fact that you can subscribe to a thread, in which case you'll get an email notice about a reply to the thread. So, the side effect is that a reply could, 'raise the dead'. That may annoy people, or it may bring back those who have wandered off. I know of cases where both results have occurred, which is why I'm ambivalent about such a post.
As to the code, where's the cursor after you run that?