AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Syed Rizwan Muhammad Rizvi
Expertise
I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.

Experience
Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > Parsing information out of a string

Topic: VB.NET



Expert: Syed Rizwan Muhammad Rizvi
Date: 5/29/2006
Subject: Parsing information out of a string

Question
If I was to put the output of the first and last name into a 2 dimensonal array and the age into a 1 dimensonal array, how would I sort corresponding information accross arrays?

toby



-------------------------

Followup To

Question -
When i have an input like:

Jan doe 23

I want to parse first name, last name and then age.

I started by using the .indexof(" ") and the first name was extracted, but with the second name I am having a bit of a time.

Please advise

Answer -
dim str() as string

str = InputStr.Split(" ".toCharArray())

strFirstName = str(0)
strLastName = str(1)
strAge = str(2)

That should do it.

Answer
I suggest that you create a type in VB
e.g.

Type Person
 FirstName as string
 SecondName as string
 Age as Integer
End Type

and then code it like this:
Dim Col as new Collection 'Or you Can use an arraylist if you want
dim tmpPerson as Person

tmpPerson.FirstName=...
tmpPerson.SecondName=...
tmpPerson.Age=...

Col.Add tmpPerson

put the above in a loop. that way you would be able to solve the problem more easily and efficiently as arrays are not the most efficient data structures available.

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.