Avoid default property as return value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a problem assigning a control with index to an object type variable with SE
no problem at all when the control isn't a member of an arra
obviously, because of my application purpose, can't refeer explicity to the objec

Objects in Form1
- Option1(0
- Option1(1
- Option

Dim WithEvents MyOption As VB.OptionButto

Private Sub Command1_Click(
Dim lobj1 As Object, lobj2 As VB.OptionButto
For Each lobj1 In Form1.Control
'change "Option2" for "Option1" and it will raise an Error 45
If lobj1.Name = "Option2" The
Set MyOption = lobj
End I

Nex
End Su

Private Sub MyOption_Click(
MsgBox "OK
End Su

Any sugestions? thnx a lot!
 
* "=?Utf-8?B?ZnJvamFzayAoZnJvamFza0Bob3RtYWlsLmNvbSk=?= said:
I have a problem assigning a control with index to an object type variable with SET
no problem at all when the control isn't a member of an array
obviously, because of my application purpose, can't refeer explicity to the object

Your problem seems to be related to VB6, so please turn to the VB6
groups: microsoft.public.vb.*.
 
frojask ([email protected]) said:
I have a problem assigning a control with index to an object type
variable with SET no problem at all when the control isn't a member
of an array obviously, because of my application purpose, can't
refeer explicity to the object

Objects in Form1:
- Option1(0)
- Option1(1)
- Option2

Dim WithEvents MyOption As VB.OptionButton

Private Sub Command1_Click()
Dim lobj1 As Object, lobj2 As VB.OptionButton
For Each lobj1 In Form1.Controls
'change "Option2" for "Option1" and it will raise an Error
459 If lobj1.Name = "Option2" Then
Set MyOption = lobj1
End If

Next
End Sub

Private Sub MyOption_Click()
MsgBox "OK"
End Sub


Any sugestions? thnx a lot!

In VB.Net this problem does not exist anymore (because we don't have and
don't need those very strange control arrays anymore (OT: why "strange"?
Well, what is the data type of a control array? "Object" or what? Why can't
you do the thing you're trying to do? How being able to add an undetermined
number of controls and handle their events without a "template" design time
instance?)). One of the reasons why I *like* VB.Net. :-)


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Back
Top