Solved

Strings and substring help

Posted on 2012-04-12
2
184 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:Mike Miller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:Mike Miller
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

696 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