473,406 Members | 2,867 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,406 software developers and data experts.

convert spaces to underscores

Hey guys,

I have a textbox where I want to find any spaces in the text and convert
them to underscores _. Can someone please give some help with this one?

Thank you,
Kevin
Feb 26 '07 #1
6 3009
Use the Replace function.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Kevin O'Brien" <ke******@usa.netwrote in message news:uv*************@TK2MSFTNGP06.phx.gbl...
Hey guys,
I have a textbox where I want to find any spaces in the text and convert them to underscores _.
Can someone please give some help with this one?

Feb 26 '07 #2
Do I have to read the text character by character and replace as I find
spaces or can I create a vairable equal to textbox.text and run replace
against that variable.

thank you for your help.

kevin
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OP**************@TK2MSFTNGP06.phx.gbl...
Use the Replace function.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Kevin O'Brien" <ke******@usa.netwrote in message
news:uv*************@TK2MSFTNGP06.phx.gbl...
>Hey guys,
>I have a textbox where I want to find any spaces in the text and convert
them to underscores _. Can someone please give some help with this one?


Feb 26 '07 #3
I got it. This is what I did...

Dim removespaces As String
removespaces = TextBox1.Text

TextBox2.Text = Replace(removespaces, " ", "_")

Thank you,

Kevin

"Kevin O'Brien" <ke******@usa.netwrote in message
news:uy**************@TK2MSFTNGP06.phx.gbl...
Do I have to read the text character by character and replace as I find
spaces or can I create a vairable equal to textbox.text and run replace
against that variable.

thank you for your help.

kevin
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OP**************@TK2MSFTNGP06.phx.gbl...
>Use the Replace function.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Kevin O'Brien" <ke******@usa.netwrote in message
news:uv*************@TK2MSFTNGP06.phx.gbl...
>>Hey guys,
>>I have a textbox where I want to find any spaces in the text and convert
them to underscores _. Can someone please give some help with this one?



Feb 26 '07 #4
I was about to post an example.

Yes, that's exactly the solution.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Kevin O'Brien" <ke******@usa.netwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
>I got it. This is what I did...

Dim removespaces As String
removespaces = TextBox1.Text

TextBox2.Text = Replace(removespaces, " ", "_")

Thank you,

Kevin

"Kevin O'Brien" <ke******@usa.netwrote in message news:uy**************@TK2MSFTNGP06.phx.gbl...
>Do I have to read the text character by character and replace as I find spaces or can I create a
vairable equal to textbox.text and run replace against that variable.

thank you for your help.

kevin
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OP**************@TK2MSFTNGP06.phx.gbl...
>>Use the Replace function.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Kevin O'Brien" <ke******@usa.netwrote in message news:uv*************@TK2MSFTNGP06.phx.gbl...
Hey guys,

I have a textbox where I want to find any spaces in the text and convert them to underscores _.
Can someone please give some help with this one?




Feb 26 '07 #5
If you are going to be doing this in various places, consider making it into
a static (Shared in VB.NET) method in a Utilities class:

Public Shared Function SpacesToUnderscores( ByVal inputText as String) As
String
Return inputText.Replace(" ","_")
End Function

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Kevin O'Brien" wrote:
I got it. This is what I did...

Dim removespaces As String
removespaces = TextBox1.Text

TextBox2.Text = Replace(removespaces, " ", "_")

Thank you,

Kevin

"Kevin O'Brien" <ke******@usa.netwrote in message
news:uy**************@TK2MSFTNGP06.phx.gbl...
Do I have to read the text character by character and replace as I find
spaces or can I create a vairable equal to textbox.text and run replace
against that variable.

thank you for your help.

kevin
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OP**************@TK2MSFTNGP06.phx.gbl...
Use the Replace function.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Kevin O'Brien" <ke******@usa.netwrote in message
news:uv*************@TK2MSFTNGP06.phx.gbl...
Hey guys,

I have a textbox where I want to find any spaces in the text and convert
them to underscores _. Can someone please give some help with this one?



Feb 26 '07 #6
Nice! Thank you both for your excellent help!

Kevin
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:12**********************************@microsof t.com...
If you are going to be doing this in various places, consider making it
into
a static (Shared in VB.NET) method in a Utilities class:

Public Shared Function SpacesToUnderscores( ByVal inputText as String) As
String
Return inputText.Replace(" ","_")
End Function

Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Kevin O'Brien" wrote:
>I got it. This is what I did...

Dim removespaces As String
removespaces = TextBox1.Text

TextBox2.Text = Replace(removespaces, " ", "_")

Thank you,

Kevin

"Kevin O'Brien" <ke******@usa.netwrote in message
news:uy**************@TK2MSFTNGP06.phx.gbl...
Do I have to read the text character by character and replace as I find
spaces or can I create a vairable equal to textbox.text and run replace
against that variable.

thank you for your help.

kevin
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OP**************@TK2MSFTNGP06.phx.gbl...
Use the Replace function.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Kevin O'Brien" <ke******@usa.netwrote in message
news:uv*************@TK2MSFTNGP06.phx.gbl...
Hey guys,

I have a textbox where I want to find any spaces in the text and
convert
them to underscores _. Can someone please give some help with this
one?




Feb 26 '07 #7

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

Similar topics

4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
7
by: PeteC | last post by:
I'm working on a web page which has some form elements in it which I need to manipulate using JavaScript. If the element is (for example, in a form called TicketForm) <INPUT...
3
by: larry | last post by:
Hi, I am a newbie to Internet programming. I have some questions about spacing in HTML control names and subsequently being able to access these input elements in JavaScript If you don't have...
1
by: Todd | last post by:
Hello, I'm am creating a CSV text import file for another application from my Access database. The other application requires a leading and following space surrounding a hyphen in the field...
12
by: Brian Henry | last post by:
first question... I have a flat file which unfortinuatly has columns seperated by nulls instead of spaces (a higher up company created it this way for us) is there anyway to do a readline with this...
14
by: Sergei Riaguzov | last post by:
I have a very strange behaviour with POST keys. Consider a test: wtf.html: === Cut === <form action="eh.php" method="POST">     <input type="checkbox" name="many spaces and. . dots. . "/>...
2
by: yawnmoth | last post by:
Say I have the following script - test.php: <? if (count($_GET) != 0) { foreach(array_keys($_GET) as $var) { echo "$var<br />"; } }
2
by: gregnowlives | last post by:
Hi i've created a simple website which allows our intranet users to add files from shared drives on the domain and structure them on web pages. (bit like sharepoint). These files are then displayed...
9
by: Jeff | last post by:
I have a legacy database table that has spaces in the field names. So I have a form that looks like this: <input type="text" name="name with space" value="some_value"> on the server I have:...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.