Solved

Parsing to get string values

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

810 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