-
textbox cursor position???
i never needed to know this until now ...
if i wanted to put text to a textbox all i would have to do was
text1.text = "hello"
and if i ever wanted to to put a line below that i would go
text1.text = "hello" & vbcrlf & "world"
however, now i need to insert words in the textbox with a command button ... i need it to insert the text where the blinking cursor is in the textbox ...
can anyone help?
-
maybe if you explain more how/when this shouldhappen someone will be able to give you a better solution. For example, it can't happen after the user clicks on a button because the focus will no longer be with the textbox.
what is the scenario or the event that triggers th need to insert text?
-
SelStart = Where the selection begins
SelLength = How long is the selection
SelText = What it contains
Basically, you only need to set the SelText.
-
what i'm trying to do is a very simplistic html editor (if i can even call it that)
its purpose is to make my coding a little faster.
every time i might need to type <html> i just want to click on a command button and insert it wherever the blinking cursor is at ...
i hope i explained myself better
-
Text1.SelText = " Hello"
or
Text1.text = Text1.text & " Hello"
-
thanks
well that was really simple ... i thought it too simple to work so i didn't even bother to try that before ...
1 more question ... which one would be more effecient ?
Text1.SelText = " Hello"
or
Text1.text = Text1.text & " Hello"
-
Sorry for giving you a choice :rolleyes:.
Well, .SelText will overwrite any selected and put the new text.
Whereas, Text1.text = Text1.text & ... will not overwrite any text, but will rather add to the textbox.
-
Text1.Text = Text1.Text & "Hello"
isn't what you're looking for.
Text1.SelText = "Hello"
replaces the text that is selected in the textbox (if there's no selected text, it adds Hello to the current cursor position.
If you wish to only add text, use
Text1.SelText = Text1.SelText & "Hello"
-
Nope, that's not really it either. Well what about this?
Code:
With Text1
.SelStart = .SelStart + .SelLength
.SelText = "Hello"
End With
-
Uh, too many posts about the same thing I think? :)
Anyway, do and use as you like theman32x.
As a tip I can say that it's not good to add too many command buttons. You could make command buttons by category. When you click a button, you get a popup menu with the tags etc. that can be add to the HTML. It's simple to do and looks kinda cool :)