473,750 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to convert a multiline textbox to a single line string?

I have a multi line text box, i'd like to store the contents of this
textbox to a text file. However when I write the value of '
textbox.text ' to the file it is written verbatim spanning many lines
if enter has been pressed.

I'd like to store the value of the textbox on one single line in the
file. How do i do this?

I assume i'll need to read new line characters from the textbox.text
string, and replace them with some token ?

Is this how I'd do it, and if so can you suggest some sample code?

Thanks,

Gary.

Jan 4 '07 #1
2 9885

ga********@mywa y.com wrote:
I assume i'll need to read new line characters from the textbox.text
string, and replace them with some token ?
The easiest way I can see of doing that for this particular exercise,
is applying the .Replace() method to the string value of the textbox.

e.g.
string textBoxValue = textBox1.Text.R eplace(Environm ent.NewLine,
"TOKEN");

Where TOKEN is the token you're using to represent it in the single
line, and Environment.New Line is a constant representing whatever a
newline is in the current environment, as different platforms have
different ways of representing this.

Jan 4 '07 #2
Such an elegent solution. This is exactly what I needed.

Thankyou Bobbo.

Gary.

Bobbo wrote:
ga********@mywa y.com wrote:
I assume i'll need to read new line characters from the textbox.text
string, and replace them with some token ?

The easiest way I can see of doing that for this particular exercise,
is applying the .Replace() method to the string value of the textbox.

e.g.
string textBoxValue = textBox1.Text.R eplace(Environm ent.NewLine,
"TOKEN");

Where TOKEN is the token you're using to represent it in the single
line, and Environment.New Line is a constant representing whatever a
newline is in the current environment, as different platforms have
different ways of representing this.
Jan 4 '07 #3

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

Similar topics

4
31063
by: Michael C | last post by:
Hi all, I'm trying to add lines to a multiline textbox. Here's what I'd like to end up with in the textbox (as an example): Line1 Line2 Line3 I've tried a couple of methods but nothing seems to be working. Code like
4
5373
by: Jason | last post by:
I have a string that looks like this? ihelloworld_zzz_yyy In a single vb.net line, I want to remove the frist character and anything after and including the first "_" resulting in : helloworld
1
3848
by: dhavalmajmundar | last post by:
Hi, I am passing the value of the Multiline Text Box from VB to Crystal. Everything was ok until the User Pressed the Enter Key to separate the line in the Multiline Textbox, Pressing Enter causes the VB to throw a msg before opening the Crystal. The Error Says: Error Generating Report. Error in Formula. In Error, it shows the ''line 1 and than in next line just the single quote character ' like this. and...
7
15481
by: Anil Gupte | last post by:
I have read a lot about getting lines from a multiline textbox in VB.Net. However, I cannot for the life of me figure out how to write to a multiline textbox. Basically, I have created an array of strings which I want to "paste" into a multiline textbox. Any ideas? -- Anil Gupte www.keeninc.net www.icinema.com
1
2345
by: Nethra | last post by:
Hi... I am trying a program which convert the multiline comment type in a program to single line comment type ie. /*have a nice day */ to //have a //nice day
2
5830
by: Nathan Sokalski | last post by:
I have a multiline TextBox that I want to display the text used to create a control in an apsx file. I want each of these to be on a separate line in the TextBox. The only way I know of to place things on separate lines in a TextBox without doing it programmatically is the following: <asp:TextBox ID="txtMultiLine" runat="server" TextMode="MultiLine"> Line 1 Line 2 Line 3 </asp:TextBox>
1
3659
by: kru | last post by:
Hi All, Simple issue I cannot figure out. I have a multiline textbox, I need to convert the string contents of this textbox into a single line string which I currently write to a textfile. I've attempted to cleanse the contents of the textbox by removing ASCII chars 0-31 which includes carriage returns and replacing all
1
7570
by: fniles | last post by:
I am using VB.NET 2008. I have a multiline textbox on the form that I would like to print when the user click on the "Print" button. With my codes below, when the text are in more than 1 page (say 3 pages) of the textbox, when it prints the text in the text box, the 2nd and 3rd pages are printed on the same page with the 1st page. So, instead of printing 3 pages, it prints 1 page with the text from page 2 and 3 are printed on top of each...
10
3797
by: JohannKotzeVet | last post by:
Good day! I have a form in Access that has a multiple line textbox (I called it cAbnormalities). This text box is populated by the user ONLY through selection of options from combo boxes. I want the selected options to each be in a seperate line, and I don't want the user to be able to edit the textbox without using the combo boxes. Here is my code when a selection is made from the combo box: Me.cAbnormalities.Locked = False...
0
9001
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9583
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9256
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8263
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6808
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4888
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.