473,386 Members | 1,694 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,386 software developers and data experts.

How do I reference a control, not its default property

I'm trying to build a collection of a few controls (a subset of controls from a report in Access) for later use in a foreach statement

Expand|Select|Wrap|Line Numbers
  1. Dim ControlList1 As New Collection ' to hold controls for formating
  2. ControlList1.Add (tbRevision) ' does not work
  3. ControlList1.Add (Me.Controls("tbChecklist"))  ' does not work either
  4.  
The collection gets the value of the default property for the control (a string), instead of the control itself.

So, how do I reference a control, not its default property?
Nov 12 '09 #1
2 1362
vb5prgrmr
305 Expert 100+
In Visual Basic 6.0 you can do something like...
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Dim O(1 To 2) As Object
  4.  
  5. Private Sub Form_Load()
  6. Set O(1) = Command1
  7. Set O(2) = Text1
  8. End Sub
  9.  
  10. Private Sub Command1_Click()
  11. O(1).Caption = "Click"
  12. O(2).Text = "Changed"
  13. End Sub
  14.  
That is just one way but I hope it helps you figure out your quandry.



Good Luck
Nov 13 '09 #2
QVeen72
1,445 Expert 1GB
Hi,

You have to declare the control and use "SET"

Dim Ctl As Control
Set Ctl = Me.Controls("TextBox1")


Regards
Veena
Nov 13 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
1
by: Kris van der Mast | last post by:
Hi, been a while since I posted a question myself instead of trying to help others out. I'm refactoring an existing web app that uses dynamic loading of user controls and a lot of...
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...
6
by: Larry | last post by:
Hi All, I am in .NET 2003 I have a form and a toolbar on the form. When the user clicks on a button on the toolbar I call the following Sub I get a crash on the last line: ...
11
by: Rimpinths | last post by:
I'm new at developing user controls in C#, and one thing I've noticed right off the bat is that the constructor gets called twice -- once at design time, once at run time. In short, I'm trying...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
9
by: =?Utf-8?B?VG9tbXkgTG9uZw==?= | last post by:
I don't know if the following is what you are looking for, but to me what you described was using a control array. If you were using vb6 that would be easy, the following articles hopefully...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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.