• 0

[vb .net] programmatically remove selected text


Question

Ok, I feel really freaking dumb for asking this, but this has proven more complicated for me than almost anything. How in god's name do I, using code and not a keyboard input, remove the selected text in a text box. I thought it would be something like:

txtbox.text.remove(txtbox.selectionstart, txtbox.selectionlength - 1)

It's obvisouly not and I have tried a million variations. Can someone enlighen me as to what the actual code would be? Maybe then I can smack myself in the head for missing something that should be easy as cake.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

how about this? it's in C#, but then again, it shouldnt matter because its .net

int location = txtbox.SelectionStart;

if(location != 0)
 ?txtbox.Text = txtbox.Text.Remove(location-1,1); ? 
txtbox.SelectionStart = txtbox.Text.Length;

STV

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.