Solved

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

Posted on 1998-12-18
6
158 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
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 36
Saving history changes to sub form 4 43
Using "ScreenUpdating" 6 65
MS Access 03, TransferText, decimal places 8 72
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…
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…
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…
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…

810 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