?
Solved

I am making an IRC chat program and I need...

Posted on 1998-12-18
6
Medium Priority
?
174 Views
Last Modified: 2010-05-03
I am making an irc chat program and when I get the names of the people in the chat room it puts them in a text box like this:
Carl Gary Mike Jhon
But I need them to be added to a list box! But if there is a space in the name like this:
Jhon Shroom Kitty Catt
It makes kitty and Catt to seperate names how should I go about making this work? If it is even possible? Also if it isn't possible, then how might I go about making it add just the names to the list box? Thanx........
0
Comment
Question by:Shroom
[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
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:idcanada
ID: 1451441

If you have te listbox read a string,
you will not have this problem of spaces.

The listbox will add it as is.

0
 
LVL 4

Expert Comment

by:idcanada
ID: 1451442
If you have te listbox read a string,
you will not have this problem of spaces.

The listbox will add it as is.
0
 

Author Comment

by:Shroom
ID: 1451443
Do u have the code for this???
0
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!

 

Author Comment

by:Shroom
ID: 1451444
I have a text box and need to add em to a list box. But I need it to make the names go like this:
The names are already like this:
Gary Mark Shaun
I need it to make a list box like this:
Gary
Mark
Shaun
--------------
Ok but i know how to do this just cut it off at the space but It if the name has a space in it like Kozy Kitten it makes Kozy Kitten 2 speperate names.
Do u have the code to make this work???
0
 

Author Comment

by:Shroom
ID: 1451445
I am rejecting ur answer cause there isn't enough info... sorry
0
 
LVL 1

Accepted Solution

by:
prozak earned 0 total points
ID: 1451446
Well if a space can be included in the persons name then you're screwed. You can't have spaces delimiting the names if a space can be included in the name because there's no way to know if you're looking at two separate names or just one name with a space in it.

Here's some sample code on adding the names to the list box (delimited with a space):

Option Explicit

Private Const strNameDelimiter As String = " "

Private Sub AddNamesToList(strNames As String, lstList As ListBox)
  Dim intPos As Integer
  Dim strParse As String
 
  'Set up the parsing string
  strParse = Trim(strNames)

  'Find the first occurrence of the delimiter
  intPos = InStr(strParse, strNameDelimiter)

  'Loop while there are still delimiters in the string
  Do While intPos <> 0
   
    'Add the name to the list box
    lstList.AddItem RTrim(Left(strParse, intPos - 1))

    'Remove the name from the list
    strParse = LTrim(Right(strParse, Len(strParse) - intPos))

    'Find the next delimiter
    intPos = InStr(strParse, strNameDelimiter)
  Loop
 
  'If there's anything left in the parsing string, add it to the list
  If strParse <> "" Then
    lstList.AddItem strParse
  End If
End Sub

Private Sub Command1_Click()
  List1.Clear
  AddNamesToList Text1.Text, List1
End Sub
 
I just set up a form with a text box that I could type in the list of names and then had a listbox and command button on the form.

I realize there are probably better ways of doing the parsing by saving of the last position and doing a call to Mid but I just went for the quick and dirty method.

If you really want to support names including a space I suggest using a comma or something else to delimit the name. Then you could just change strNameDelimiter = "," and it would work the same way.

Hope this helps...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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