Solved

Getting info from a string in a listbox

Posted on 1998-10-09
3
135 Views
Last Modified: 2010-04-30
Say there are multiple strings of information in a list box with a person's first name then last name then phone number in that order, and there is a button next to the list box that should only get the selected person's first name from the string and stores it in a global variable. How do you code the button so this occurs?
0
Comment
Question by:Gardiun
[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
3 Comments
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1439061
you should separate each item with a character :

ex :
 cbCombo.Add sFirstName & ";" & sLastName & ";" & sPhone

or

 cbCombo.Add sFirstName & vbTab & sLastName & vbTab & sPhone


in the command button, do as follow :

 sLine = cbCombo.List(cbCombo.ListIndex)
 nPos = Instr(sLine , ";") ' or nPos = Instr(sLine , vbTab)
 sFirsName = Left(sLine , 1, nPos-1)

0
 

Author Comment

by:Gardiun
ID: 1439062
It has a problem with this line:
sFirsName = Left(sLine , 1, nPos-1)

The message read "wrong number of arguments or invalid property assignment." What did you declare nPos as?
0
 
LVL 14

Expert Comment

by:waty
ID: 1439063
Dim sFirsName as String
dim sLine as String
dim nPos  as long
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 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