Solved

VB.NET STRING FUCNTION

Posted on 2010-11-30
2
344 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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