Solved

Parsing to get string values

Posted on 2008-10-07
2
136 Views
Last Modified: 2012-05-05
I would like to extract the string in Label4.text = "Enrollment VI-F" (But this  label4.text could be anything)
into separate lables.
For example here..
Label1.text = "Enrollment"
Label2.text = "VI"
Label3.text = "F"
0
Comment
Question by:zachvaldez
2 Comments
 
LVL 4

Accepted Solution

by:
Mitzs earned 150 total points
ID: 22660909
You can Split the string and store each value as an element of a string array based on a seperator.

Dim values As String
values = "SomeString, A, BBBB, CCC, TEST"
Dim sites As String() = Nothing
sites = values.Split(",")
Dim s As String
For Each s In sites
     Console.WriteLine(s)
Next s


OR you if you have multiple seperator then use following

Dim values As String
values = "SomeString, A, BBBB, CCC; TEST"
Dim sites As String() = Nothing
Dim sep(3) As Char
sep(0) = ","
sep(1) = ":"
sep(2) = ";"
sites = values.Split(sep, 4)
Dim s As String
For Each s In sitesConsole.WriteLine(s)
Next s

Mitzs



0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 100 total points
ID: 22661311
Try with:

Dim text as string = "Enrollment VI-F"
Dim seps as String = " -,;"
Dim parts() as String

parts = text.Split(seps.ToCharArray(), 4)
label1.Text = parts(0)
label2.Text = parts(1)
label3.Text = parts(2)

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create XML 5 46
Help with WinAPI Signatures in VB.NET for SetWindowSubclass 2 34
fso.FolderExists("\\server\HiddenFolder$") 4 46
Advice in Xamarin 21 44
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

939 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

10 Experts available now in Live!

Get 1:1 Help Now