|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Replace Selected TextCan anyone tell me why this isn't working in VB.NET 2003? And no, the
problem lies between the keyboard and the back of the chair is not a valid answer!!!! Me.TextBox1.SelectionStart = 0 Me.TextBox1.SelectionLength = 3 Me.TextBox1.SelectedText = "MOO" Thanks "jvb" <gome***@gmail.com> schrieb Here it works. Where do you execute this?> Can anyone tell me why this isn't working in VB.NET 2003? And no, > the problem lies between the keyboard and the back of the chair is > not a valid answer!!!! > > Me.TextBox1.SelectionStart = 0 > Me.TextBox1.SelectionLength = 3 > Me.TextBox1.SelectedText = "MOO" Armin This code was excuted from the parent form (to test) as well as from
the find/replace form. This is the solution i had to implement... Dim HoldIndex As Int32 HoldIndex = Me.TextBoxToEdit.Text.IndexOf(Me.cboFind.Text) Me.TextBoxToEdit.Text = Me.TextBoxToEdit.Text.Remove(HoldIndex, Len(Me.cboFind.Text)) Me.TextBoxToEdit.Text = Me.TextBoxToEdit.Text.Insert(HoldIndex, cboReplace.Text) Thanks for all your help! JVB I do not know why your code is not working:
Does the textbox have 3 characters in the textbox Is the textbox readonly or locked Is the textbox databound Do you receive an exception What does "isn't working" mean may I suggest: try dim sTemp as string = ctype(Me.TextBox1.Text,string) if stemp.length > 3 then me.textbox1.text = string.format("{0}{1}","MOO",sTemp.Substring(3)) else me.textbox1.text = string.format("{0}{1}","PEBKAC #1",sTemp) end if catch ex as exception msgbox string.format("PEBKAC #2{0}{1}",vbcrlf, ex.tostring) end try Show quoteHide quote "jvb" <gome***@gmail.com> wrote in message news:1140122990.846619.265580@z14g2000cwz.googlegroups.com... > Can anyone tell me why this isn't working in VB.NET 2003? And no, the > problem lies between the keyboard and the back of the chair is not a > valid answer!!!! > > Me.TextBox1.SelectionStart = 0 > Me.TextBox1.SelectionLength = 3 > Me.TextBox1.SelectedText = "MOO" > > Thanks > Sorry for being so vague...When i execute the code above, it replaces
the selected text with an empty string. I will give your suggestion a try. I am trying to get it to replace the selected text in the textbox with a new value...a find/replace function.
by default, public or private?
Getting current user name Reference to a variable Getting Color Depth / Quality of display adpater / screen need help on DateDiff function! Which collection object to use similar to SortedList\Hashtable printing problem with dotmatrix printer using vb.net BindingSource.AddNew Properties of a Property Property of List of Classes |
|||||||||||||||||||||||