|
-
Nov 25th, 2001, 06:59 AM
#1
Thread Starter
Lively Member
Which type does Collection object accept?
Hi,
Why does the followin code says "Type missmatch "?
If c.Container.Caption = "Info" Then
If TypeOf c Is ComboBox Then valColl.Add (c.Text), c.Index
If TypeOf c Is label Then labelColl.Add c.Caption, c.Index
If TypeOf c Is TextBox Then valColl.Add c.Text, c.Index
End If
Next c
These follwing 3 lines give the error "Type missmatch"
If TypeOf c Is ComboBox Then valColl.Add (c.Text), c.Index
If TypeOf c Is label Then labelColl.Add c.Caption, c.Index
If TypeOf c Is TextBox Then valColl.Add c.Text, c.Index
Thanks
-
Nov 25th, 2001, 07:11 AM
#2
The second argument to the Add method of a Collection object is the Key.
Key must be a string. You're adding the Index of the object.
You must explicitly change that to a string
VB Code:
If TypeOf c Is ComboBox Then valColl.Add (c.Text), [b]CStr(c.Index)[/b]
Or use the Index argument of the collection object which is the third argument of the Add method.
Best regards
-
Nov 25th, 2001, 07:22 AM
#3
Thread Starter
Lively Member
Thanks Joacim Andersson
it worked !
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
|