473,388 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Avoid default property as return value

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!
Nov 20 '05 #1
2 1165
* "=?Utf-8?B?ZnJvamFzayAoZnJvamFza0Bob3RtYWlsLmNvbSk=?=" <see in my name> scripsit:
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.*.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
"frojask (fr*****@hotmail.com)" <see in my name> schrieb
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

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: mic | last post by:
I've spent last hour trying to debug my code, when I found out that instead of executing object's method I accidentaly overridden it with variable (see below example). My stupid! But as the system...
0
by: Andy Eshtry | last post by:
Dear Friends I have a urgent problem to solve. I have created a class and its collection and then bind it to a datagrid but got the following error. Please help. Thanks in advance. Andy Eshtry ...
8
by: Mark | last post by:
When my form goes to a new record, I have a procedure that copies the last record added to the form's underlying table into the form. The intent is that a series of new records may have the same...
5
by: Chuck Bowling | last post by:
Maybe I'm doing something wrong or just don't understand the concept, but i'm having a problem with default properties. My impression of how a default property should act is this; MyClass c =...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
4
by: Dennis | last post by:
I am trying to set the default design proerties in a control I have derived from the Panel Class. I thought I'd found how to do it from the MSDN but the following line doesn't work: Inherits...
1
by: Bernard Bourée | last post by:
I would like to achieve the following goal: design a class with a default property called dVal where I could store and get a decimal value WITHOUT the need to write the property. I have the...
14
by: dave.dolan | last post by:
Basically I'd like to implement the composite design pattern with leaves that are either of reference or value types, but even using generics I can't seem to avoid boxing (using ArrayList or...
9
by: Eric | last post by:
Hi Everyone, I'm writing a UserControl that exposes a property of the type System.Drawing.Image, like this: Public Property DefaultImage() As Image Get Return propDefaultImage End Get...
10
by: Brad Baker | last post by:
I have an asp.net/csharp application that requires a particular variable to work properly. This variable is usually passed via a query string in the URL when the application is first run but under...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.