Solved

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

Posted on 1998-12-18
6
169 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

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