Solved

Getting info from a string in a listbox

Posted on 1998-10-09
3
130 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

816 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now