Google Answers Logo
View Question
 
Q: Visual Basic Question, parsing out a Variable that is comma deliminated. ( Answered 4 out of 5 stars,   1 Comment )
Question  
Subject: Visual Basic Question, parsing out a Variable that is comma deliminated.
Category: Computers > Programming
Asked by: pmclinn-ga
List Price: $10.00
Posted: 31 Oct 2002 21:21 PST
Expires: 30 Nov 2002 21:21 PST
Question ID: 95038
I have a visual basic variable that is holding comma deliminated
information.  What is the easiest way to seperate this information out
into seperate text boxes?  I always have 3 commas in my variable.

Example: MyString = 1,Doe,John,477-76-2222 

text1.text = 1
text2.text = Doe
text3.text = John
text4.text = 477-76-2222

[Note: the information between the commas changes line to line.]

Clarification of Question by pmclinn-ga on 31 Oct 2002 21:27 PST
Note:  The information changes in "MyString" because I'm importing
information in from a text file and then writing it to a database.
Answer  
Subject: Re: Visual Basic Question, parsing out a Variable that is comma deliminated.
Answered By: webadept-ga on 31 Oct 2002 21:46 PST
Rated:4 out of 5 stars
 
Hi, 


The VB Split and Join functions support only one delimiter, and since
you are always using a comma for you delimination, there should be no
problems with using that command.

This article will show you exactly how to do that.

VB CodeGuru
http://www.codeguru.com/vb/articles/2119.shtml

Query

+"VB" +Split +Function

thanks, 

webadept-ga
pmclinn-ga rated this answer:4 out of 5 stars and gave an additional tip of: $1.00
Your answer works and I did not have to add in module overhead.  Thank
you!  This solution is fast and efficient!  The only thing missing,
that would of given you a 5 star rating, was how the "output" would
look.

Comments  
Subject: Re: Visual Basic Question, parsing out a Variable that is comma deliminated.
From: vamsikris-ga on 31 Oct 2002 22:50 PST
 
Hi,
I have a very  simple way to solve the problem.Try this code in the
event handler u want to execute your task. I have user text control
array for display.I think that should not be problem

Dim mystring As String
mystring = "1,vamsi,krishna,7248038"
temp = mystring
i = 0
Do
If InStr(1, temp, ",") <> 0 Then
a = Mid(temp, 1, InStr(1, temp, ",") - 1)
Text1(i) = a
temp = Mid(temp, InStr(1, temp, ",") + 1)
Else
a = temp
Text1(i) = a
Exit Do
End If
i = i + 1
Loop Until Len(temp) = 0


Hope your problem will be solved
regards
Vamsi Krishna
India

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy