473,325 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Replace Selected Text

jvb
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

Feb 16 '06 #1
4 6128
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
"jvb" <go*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.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

Feb 16 '06 #2
jvb
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.

Feb 16 '06 #3
"jvb" <go*****@gmail.com> schrieb
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"


Here it works. Where do you execute this?
Armin

Feb 16 '06 #4
jvb
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

Feb 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dave | last post by:
I have an Access 2K application that is distributed to about a dozen users (all with identical NT environments and identical Access versions, object libraries and service packs). I am using the VBA...
4
by: Cor | last post by:
Hi Newsgroup, I have given an answer in this newsgroup about a "Replace". There came an answer on that I did not understand, so I have done some tests. I got the idea that someone said,...
6
by: jiing24 | last post by:
I try to use regexp to replace some html tags in DOM, but the result seems some problems, ================================ <Script language="javascript" type="text/javascript"> var config =...
4
by: Tony WONG | last post by:
i have an array data, like this 1234,4565,7890,3478 i use replace to replace "," to ";" for fitting into the data input however, i choose record according to the "selected" checkbox, then...
1
by: cweeks | last post by:
Dev env: VS 2005 C# Express, .Net Framework 2.0 I am trying to programmatically select an item in a listbox on a web page. The first thing I do is go through and de-select any selected items. ...
0
by: Pascal | last post by:
-- bonjour how to replace an item of a listbox (that I selected by a double click in the list to post it in a txtbox) by its version modified in this txtbox when i make chrw(13)? If KeyAscii...
8
by: Captain Dondo | last post by:
I have an array(?) (sorry, I'm new* to python so I'm probably mangling the terminology) that looks like this: I want to replace every instance of 'tooth.seiner.lan' with 'localhost'. There...
2
by: King of the R.O.U.S.'s | last post by:
Hi All How do I replace selected text in a textarea with JavaScript? I have a text area that the user can select what they want then press a button that will pick up the selected text, make...
10
by: angelicdevil | last post by:
ok i have a list of data that gets displayed in listbox... i want tht when i select any value in tht listbox and click on rename it should rename tht in the database with the value i provide in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.