Solved

VB.NET STRING FUCNTION

Posted on 2010-11-30
2
337 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
ID: 34240377
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
ID: 34240653
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net dynamic formulas in runtime 11 74
Error handling in asp.net site 5 24
start a process from a service 3 21
VB.net and sql server 4 33
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

786 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