Solved

Parsing to get string values

Posted on 2008-10-07
2
141 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
[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 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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