Solved

Parsing to get string values

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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.

708 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

20 Experts available now in Live!

Get 1:1 Help Now