473,385 Members | 1,925 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,385 software developers and data experts.

Extracting Parts of a String

Hello,

I have a question about manipulating string in VB.NET2003.

I have a string that looks as follows:
MyString = "1st garbage blah, blah.. " & vbCrLf & _
"==============================" & vbCrLf & _
"2nd garbage blah, blah.. " & vbCrLf & _
"==============================" & vbCrLf & _
"3rd garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"4th garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"5th garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"6th garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"7th garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"8th garbage blah, blah.. " & vbCrLf
From this string, I would like to get rid of all the separator lines
shown below:
"==============================" & vbCrLf & _
"------------------------------" & vbCrLf & _

And make a new string that contains the contents of MyString without
those separator lines. Like this:
NewString = "1st garbage blah, blah.. " & vbCrLf & _
"2nd garbage blah, blah.. " & vbCrLf & _
"3rd garbage blah, blah.. " & vbCrLf & _
"4th garbage blah, blah.. " & vbCrLf & _
"5th garbage blah, blah.. " & vbCrLf & _
"6th garbage blah, blah.. " & vbCrLf & _
"7th garbage blah, blah.. " & vbCrLf & _
"8th garbage blah, blah.. " & vbCrLf

I've been digging String methods for a while but still could not find
out how I can do this operation.
Can anyone give me an idea as to how to do this operation?

Thank you very much in advance!
Jan 3 '08 #1
2 1555
"thomasc" <th*********@gmail.comschrieb
Hello,

I have a question about manipulating string in VB.NET2003.

I have a string that looks as follows:
MyString = "1st garbage blah, blah.. " & vbCrLf & _
"==============================" & vbCrLf & _
"2nd garbage blah, blah.. " & vbCrLf & _
"==============================" & vbCrLf & _
"3rd garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"4th garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"5th garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"6th garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"7th garbage blah, blah.. " & vbCrLf & _
"------------------------------" & vbCrLf & _
"8th garbage blah, blah.. " & vbCrLf
From this string, I would like to get rid of all the separator lines
shown below:
"==============================" & vbCrLf & _
"------------------------------" & vbCrLf & _

And make a new string that contains the contents of MyString without
those separator lines. Like this:
NewString = "1st garbage blah, blah.. " & vbCrLf & _
"2nd garbage blah, blah.. " & vbCrLf & _
"3rd garbage blah, blah.. " & vbCrLf & _
"4th garbage blah, blah.. " & vbCrLf & _
"5th garbage blah, blah.. " & vbCrLf & _
"6th garbage blah, blah.. " & vbCrLf & _
"7th garbage blah, blah.. " & vbCrLf & _
"8th garbage blah, blah.. " & vbCrLf

I've been digging String methods for a while but still could not
find out how I can do this operation.
Can anyone give me an idea as to how to do this operation?

Thank you very much in advance!
Use the String's Replace method. Replace "-" by "" (String.Empty). Mind that
Replace is a function returning a new String.
Armin

Jan 3 '08 #2
"Armin Zingler" <az*******@freenet.deschrieb

I've been digging String methods for a while but still could not
find out how I can do this operation.
Can anyone give me an idea as to how to do this operation?

Thank you very much in advance!

Use the String's Replace method. Replace "-" by "" (String.Empty).
Mind that Replace is a function returning a new String.
Forget it...

Better:

s = s.Replace("==============================" & vbCrLf, String.Empty)
s = s.Replace("------------------------------" & vbCrLf, String.Empty)
Armin
Jan 3 '08 #3

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

Similar topics

3
by: Abby Lee | last post by:
I have a string with 10 charaters 123456789A. I only want the first 6 charaters followed by the last two...getting rid of the 7th and 8th charaters. If I use document.forms.MyTextBox.value =...
2
by: bozdog | last post by:
I have recently imported several fields from a spreadsheet(excel) and wish to update a field using an update query. The particular field is imported as a text string and defines a path for a...
2
by: Dickyb | last post by:
Extracting an Icon and Placing It On The Desktop (C# Language) I constructed a suite of programs in C++ several years ago that handle my financial portfolio, and now I have converted them to...
3
by: news | last post by:
I am trying to get at the source of a web page. Looking at the innerHTML element is only part of the story. In IE, right-clicking on various different parts of the page gives me different results...
4
by: dor | last post by:
i have an input file named input.txt where all the data looks like this: (4,10) 20 (5,3) 13 (7,19) 6 .. .. .. the numbers are random. i need to use every number in each line
1
by: rpjd | last post by:
I am completely new to this so please bear with me here. My project involves a webpage executing php scripts via an xmlhttprequest which queries a database and returns data to the webpage. This code...
4
by: Keith Wilby | last post by:
On a bit of a no-brainer with this. I have a field containing composite data which is imported from another system. Here's a sample: ...
10
by: Dan | last post by:
I have a number of strings that represents time. 1w 2d 3h 15m 2d 3h 15m 4h 30m 45m I want to extract the number parts of my strings into separate variables for Weeks, Days, Hours and...
0
by: thomasc | last post by:
Hello, I have a question about manipulating string in VB.NET2003. I have a string that looks as follows: MyString = "1st garbage blah, blah.. " & vbCrLf & _ "=============================="...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.