[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Strings and substring help

Posted on 2012-04-12
2
Medium Priority
?
188 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 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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