Solved

Strings and substring help

Posted on 2012-04-12
2
178 Views
Last Modified: 2012-04-12
I have 3 strings

myString1 = glengary
myString2 = glen gary glen ross xyz blah
myString3 = glengaryglenrossxyzblah
myString4 = ""

The values of these strings can (and will) change. I'm just using the assigned values as an example. The only thing for certain is that myString2 will always lead with myString1 (but may have spaces) and follow with unwanted text.

What is the best way to get to:
myString4 = glen gary
0
Comment
Question by:mwmiller78
2 Comments
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 37839983
Please try:
Dim myString1 = "glengary"
Dim myString2 = "glen gary glen ross xyz blah"
Dim myString3 = "glengaryglenrossxyzblah"
Dim myString4 = ""

Dim i1 As Integer, i2 As Integer = 0

For i1 = 0 To myString1.Length - 1
	While (myString2(i2) = " ")
		i2 += 1
	End While
	
	i2 += 1
Next

myString4 = myString2.Substring(0, i2)

Open in new window

0
 

Author Closing Comment

by:mwmiller78
ID: 37840026
This works. I ended up kind of doing something similar. I just created a loop that took off the last letter of the string until I got the desired value. Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now