Passing Controls to a vb form

Posted on 2003-02-20
Medium Priority
Last Modified: 2010-05-01
I am new about vb programming. Please can you tell me how can I send control names froma vb form to another
Question by:naimyildiz
LVL 11

Accepted Solution

rdrunner earned 200 total points
ID: 7987245
You can even pass the whole control to another form...

You just need to declare a variable to hold the control.

But most of the times this is not needed. You should call functions and pass a control along with the function call.

(by accessing a control "directly" you can cause side effects...

anyway... here are some exampels how to...

Direct access to the control:
form1.text1.Value = "data from from 2"

Passing the control:
(in form2)
Public mycontrol As Control

(in form1)
set form2.mycontrol =  me.text1

Passing a control in a function
Public sub fillList(ListTofill As ListBox, sql As String)
End Function

Call this function:
fillList me.list1, "Select * from bla"


Expert Comment

ID: 8901373
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
LVL 49

Expert Comment

ID: 8963954
Moderator, my recommended disposition is:

    Accept rdrunner's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As a person who answers a lot of questions, I often see code that could be simplified, made easier to read, and perhaps most importantly made easier to maintain if the code was modified to use the Select Case statement. This article explains how to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question