Solved

VB.NET STRING FUCNTION

Posted on 2010-11-30
2
329 Views
Last Modified: 2012-06-21
Hello Experts

 I am getting a data from the database column in the following format, I am trying to retrieve the last word after ":"

Sometimes I may get 3 strings concatenated with colon or sometimes 4, regardless of this I want to get the last name

POSelID: p502<br>Ice Creams:Neapolitan
POSelID: p564:o26:6m<br>Film Quote Babygrow - The Force is Strong in This One:6m
POSelID: p502<br>Ice Creams:TestOption

Please can someone let me know how can I get the exact value after retrieving it from  the DB column,

AttributeName = UCase(row.Item("options"))  
ex: AttributeName = Neapolitan

Thanks
0
Comment
Question by:newbie27
2 Comments
 
LVL 17

Accepted Solution

by:
Zhaolai earned 500 total points
Comment Utility
Try this:
Dim strTemp As String = "POSelID: p502<br>Ice Creams:Neapolitan"

        Dim strLastName As String = strTemp.Substring(strTemp.LastIndexOf(":") + 1)

Open in new window

0
 

Expert Comment

by:PhilosW
Comment Utility
Try This:
         Dim _lstTemp As List(Of String) = "POSelID: p502<br>Ice Creams:Neapolitan".Split(":").ToList()
         Dim _lastName As String = _lstTemp(_lstTemp.Count - 1)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

12 Experts available now in Live!

Get 1:1 Help Now