|
-
Nov 13th, 2000, 02:21 AM
#1
Thread Starter
Addicted Member
I need to check if the user's name has been added into a listbox. As soon as it is I need to change the user form's caption to display the correct status.
Code:
If lstConnections.AddItem = txtName.Text Then
frmMain.Caption = "SmallTalk - Now Serving"
End If
This is the code I thought would work, but actually it stirs the following error, "Compile error - Argumant not optional."
Why did I get this error and How will I be able to check for the user's name added to the listbox in order to be able to set the correct status for the form's caption?
I appreciate all of your time and effort,
Daniel Christie
VB 5 and 6 Enterprise Editions,
Html, Java scipt, Vb script,
& etc...
http://www.qwcd.com
-
Nov 13th, 2000, 03:00 AM
#2
AddItem is used to add items. Use List(indexnro) instead.
List(0) for first item, List(1) for second etc.
You can check number of items with ListIndex. Remember that last List item is List(ListCount - 1).
ListIndex tell you which one of the items is selected.
Hope this helps,
-
Nov 13th, 2000, 08:57 AM
#3
New Member
hi
not sure.... but u may be able to use the "Instr" function to check if what u have in txtname.text is in lstConnections
hope that give u another option!!
Sanj
-
Nov 13th, 2000, 11:15 AM
#4
_______
<?>
'if you load the caption when you load the name you
'don't have to check
'ie. list1.additem text1.text
'frmWhat.Caption = What
'I don't see as you need to check but if you want to
Code:
Option Explicit
'this can be any event you load the listbox from
Private Sub Command1_Click()
List1.AddItem Text1.Text
List1_ItemCheck (List1.ListCount - 1)
End Sub
Private Sub List1_ItemCheck(Item As Integer)
List1.ListIndex = List1.ListCount - 1
If List1.Text = Text1.Text Then
If lstConnections.AddItem = txtName.Text Then
frmMain.Caption = "SmallTalk - Now Serving"
End If
End If
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|