Solved

Parsing to get string values

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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

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 …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

626 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