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

Removing items from string & adding new line

I have a string which looks like this - sometext;;sometext;;sometext;;sometext

i'd like to have it displaying on a page looking like this

sometext
sometext
sometext
sometext

i know i need a loop and a split, but i'm not sure how to get it working, any help would be great, thanks
Sep 26 '07 #1
13 1748
Killer42
8,435 Expert 8TB
Not necessarily. If we assume for the moment that your string is in a variable called YourString and there's a multiline textbox called Text1 on the form, try this...

Expand|Select|Wrap|Line Numbers
  1. Text1.Text = Replace(YourString, ";;", vbNewLine)
Sep 26 '07 #2
jrtox
89
I have a string which looks like this - sometext;;sometext;;sometext;;sometext

i'd like to have it displaying on a page looking like this

sometext
sometext
sometext
sometext

i know i need a loop and a split, but i'm not sure how to get it working, any help would be great, thanks

Where did you store your String"sometext;;sometext;;sometext;;sometext"?

lets say that your "sometext;;sometext;;sometext;;sometext" is the object Text1.
then we can do coding as:
Text1.Text = Replace(Text1.Text, ";;", vbNewLine)

Note:
During Design time set Multiline to TRUE.

Regards
Sep 27 '07 #3
ideally i'd like to have it display in either a label or via response.write

the solutions that have been posted make the string sometext;;sometext;;sometext etc.. display as

sometext sometext sometext - but with no new line breaks, how would i get it to display as
sometext
sometext
sometext etc.

current code

> lblmach.Text = Replace(stringmach, ";;", vbNewLine)
Sep 27 '07 #4
QVeen72
1,445 Expert 1GB
Hi,

Make Labels's property WordWrap = True and display..

Label1.Caption = Replace(MyString,";;",vbCrLf)

REgards
Veena
Sep 27 '07 #5
i'm using vs2005, a label control doesnt seem to have wordwrap.
Sep 27 '07 #6
creative1
274 100+
If you are using Textbox to display results then, the only thing you need to do is set Multiline property then try this code
Text1.Text = Replace(YourString, ";;", vbNewLine)

If you are using label then this code will work as it is.

regards
farhana
Sep 27 '07 #7
output from a label
sometext sometext sometext
Sep 27 '07 #8
QVeen72
1,445 Expert 1GB
i'm using vs2005, a label control doesnt seem to have wordwrap.
Hi,

for VB.net 2005, Label Control will display MultiLine by default, u dont have to set any properties...


REgards
Veena
Sep 27 '07 #9
yes you are right, however the replace line is only removing the commas from the delimited string, it is not adding a new line in between each word. therefore the text will display not as a multiline, but as one string

the string is similar to this some text;;text;;more text;;even more text;; !
Sep 27 '07 #10
QVeen72
1,445 Expert 1GB
yes you are right, however the replace line is only removing the commas from the delimited string, it is not adding a new line in between each word. therefore the text will display not as a multiline, but as one string
Hi,

New Line will be added, only if it finds ";;" ...
If it encounters only one semicolon, new line will not be added.
You need to check the String again..


Regards
Veena
Sep 27 '07 #11
before replace line -

Leaflets;;Brochures to 50,000+ colour;;All stationary, including letterheads, business compliment slips;;NCR carbonless options

after replace line -

Leaflets Brochures to 50,000+ colour All stationary, including letterheads, business compliment slips NCR carbonless options
Sep 27 '07 #12
QVeen72
1,445 Expert 1GB
Hi,

You must be using ASP.net, my code was for VB.net.
I don't know why NewLine does not work, anyway here is the workaround:
say your string variable is MyString

Expand|Select|Wrap|Line Numbers
  1.         Dim TArr
  2.         Dim i As Integer
  3.         TArr = MyString.Split(";;")
  4.         For i = 0 To UBound(TArr)
  5.             Response.Write(TArr(i) & "<br>")
  6.         Next
  7.  
Regards
Veena
Sep 27 '07 #13
fantastic! thanks alot!
Sep 27 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jeremy Owens-Boggs | last post by:
We are trying to implement a dual list box selection where you have two list boxes, You highlight items in the right side list box, click a button and this moves those items over to the left hand...
4
by: Guadala Harry | last post by:
I want to create a STATIC method that removes all items from the Cache. Questions: 1. Is a safe thing to do (any threading issues?) 2. Is the following code a good way to get the job done -...
2
by: Chris | last post by:
I find tons of info on adding, but what about removing an item dynamically? I'm cycling through the list and removing users that have special rights. I've tried things like: ...
20
by: Ash Phillips | last post by:
Hi Everyone, I have this program I wrote in VB6 for family use. It's a DVD Database just for me to keep track of them cause I have so many lol. In VB6, I could add items to the ListView in...
23
by: Peter Row | last post by:
Hi, I am currently working on a VB.NET project that has been going for quite a while. In the past it has been developed with a lot of compatibility VB6 functions and constants, e.g Left(),...
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
7
by: =?Utf-8?B?Sm9lbCBNZXJr?= | last post by:
I have created a custom class with both value type members and reference type members. I then have another custom class which inherits from a generic list of my first class. This custom listneeds...
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, In my application I need to periodically remove all current items from a ListView and add a new set into it. The following abbreviated code contains the basic idea: private void...
0
by: Adam Salisbury | last post by:
**To members of microsoft.public.dotnet.framework, apologies for the crosspost. I originally posted this message into that group however have since realised this may have been a better...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...

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.