Really Easy Computer Q...rep Reward

Watch
This discussion is closed.
The_Barman
Badges: 0
Rep:
?
#1
Report Thread starter 16 years ago
#1
When using visual basic through word.....what does .ActiveControl do and mean....
0
PQ
Badges: 21
Rep:
?
#2
Report 16 years ago
#2
(Original post by VBAHelp)
Identifies and allows manipulation of the control that has the focus.

Syntax

object.ActiveControl

The ActiveControl property syntax has these parts:

Part Description
object Required. A valid object.
Remarks

The ActiveControl property is read-only and is set when you select a control in the interface. You can use ActiveControl as a substitute for the control name when setting properties or calling methods.

Copyright(c) 1996 Microsoft Corporation.
(Original post by VBAHelp Example)
The following example uses the ActiveControl property in a subroutine that tracks the controls a user visits. The Enter event for each control calls the TraceFocus subroutine to identify the control that has the focus.
To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains the following controls:

· A ScrollBar named ScrollBar1.
· A ListBox named ListBox1.
· Two OptionButton controls named OptionButton1 and OptionButton2.
· A Frame named Frame1.

Dim MyControl As Control

Private Sub TraceFocus()
ListBox1.AddItem ActiveControl.Name
ListBox1.List(ListBox1.ListCount - 1, 1) = ActiveControl.TabIndex
End Sub

Private Sub UserForm_Initialize()
ListBox1.ColumnCount = 2
ListBox1.AddItem "Controls Visited"
ListBox1.List(0, 1) = "Control Index"
End Sub

Private Sub Frame1_Enter()
TraceFocus
End Sub

Private Sub ListBox1_Enter()
TraceFocus
End Sub

Private Sub OptionButton1_Enter()

TraceFocus
End Sub

Private Sub OptionButton2_Enter()
TraceFocus
End Sub

Private Sub ScrollBar1_Enter()
TraceFocus
End Sub

Copyright(c) 1996 Microsoft Corporation.
?
0
The_Barman
Badges: 0
Rep:
?
#3
Report Thread starter 16 years ago
#3
That was great except the fact i didn't understand it very well.....can you maybe explain it to me.....in easier terms lol
0
kikzen
Badges: 14
Rep:
?
#4
Report 16 years ago
#4
(Original post by The_Barman)
That was great except the fact i didn't understand it very well.....can you maybe explain it to me.....in easier terms lol
im not sure but i think that it just returns the name of the control (the object) that currently has focus

so if you click on a textbox, the name of the textbox is passed to ActiveControl. or something.
0
PQ
Badges: 21
Rep:
?
#5
Report 16 years ago
#5
(Original post by kikzen)
im not sure but i think that it just returns the name of the control (the object) that currently has focus

so if you click on a textbox, the name of the textbox is passed to ActiveControl. or something.
Just what I was about to say - but it only returns the name if you use .ActiveControl.name - you can change the second part ot return any property you ask for.
0
The_Barman
Badges: 0
Rep:
?
#6
Report Thread starter 16 years ago
#6
thanx all....i think i understand.....i've awarded Pencil Queen the rep but i'll rep you tomorrow for ur clearer explanation....thanx!!
0
X
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

How will you be receiving your results?

Going into school to pick them up (196)
33.39%
Receiving them online / by email (291)
49.57%
I still don't know (100)
17.04%

Watched Threads

View All