|
-
Nov 6th, 2000, 03:50 AM
#1
Thread Starter
Member
Does anyone know if :
1. You can pass controls through to functions and change their properties.
2. How to do it!
Cheers Guys...
-
Nov 6th, 2000, 04:50 AM
#2
Addicted Member
O.K.
The simplist way of doing this is to have a parameter in you function that is of type OBJECT. Say you have a control on your form, such as TEXT1, and a function called ChangeText that you want to alter the text property of the control. This example calls the function in the Form_Load event.
Sub Form_Load()
dim boolResult as Boolean
boolResult = ChangeText(TEXT1)
end sub
Public Function ChangeText(TextControl as Object) as Boolean
TextControl.Text = "My New Text"
ChangeText = True
End Function
-
Nov 6th, 2000, 08:11 AM
#3
Hyperactive Member
use TypeName to check of the Object passed is a TextBox
i.e.
if TypeName(Object)="TextBox" then
...
end if
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Nov 6th, 2000, 08:27 AM
#4
You can also specify the type as Control.
Code:
Sub Change(ctl As Control)
If TypeOf ctl Is TextBox Then ctl = "HELLO"
End Sub
-
Nov 6th, 2000, 08:34 AM
#5
Thread Starter
Member
Cheers Guys
Cheers fellas that has got me sorted!
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
|