dwe0608
asked on
URGENT: Textboxes on a Picture Box
Hi All,
If I have 10 textboxes on a form as well as two pictureboxes
3 are located in picturebox1, 3 are located in picturebox2
4 are outside of the pictureboxes and are just on the form
How can I enable and disable the textboxes inside picturebox1 using a for ... next loop ?
MTIA
Darrin
If I have 10 textboxes on a form as well as two pictureboxes
3 are located in picturebox1, 3 are located in picturebox2
4 are outside of the pictureboxes and are just on the form
How can I enable and disable the textboxes inside picturebox1 using a for ... next loop ?
MTIA
Darrin
ASKER
And if I wanted to enable all textboxes - the following code marked by ?? would be helpful
Private Sub EnableDisableTextboxes(ByV al Status As Boolean, optional ByRef ContainedIn As PictureBox = nothing)
Dim txt As Control
For Each txt In Me.Controls
if not Ismissing(ContainedIn) and ?? not containedin is nothing ?? then
If txt.Container Is ContainedIn Then txt.Enabled = False
else
txt.Enabled = False
end if
Next
End Sub
MTIA
Darrin
Private Sub EnableDisableTextboxes(ByV
Dim txt As Control
For Each txt In Me.Controls
if not Ismissing(ContainedIn) and ?? not containedin is nothing ?? then
If txt.Container Is ContainedIn Then txt.Enabled = False
else
txt.Enabled = False
end if
Next
End Sub
MTIA
Darrin
Tim already give you the solution, the only thing he should use status to set the enabled flag
ie.
Private Sub EnableDisableTextboxes(ByV al Status As Boolean, Optional ByRef ContainedIn As PictureBox = Nothing)
Dim txt As Control
For Each txt In Me.Controls
If Not IsMissing(ContainedIn) And Not ContainedIn Is Nothing Then
If txt.Container Is ContainedIn Then txt.Enabled = Status
End If
Next
End Sub
ie.
Private Sub EnableDisableTextboxes(ByV
Dim txt As Control
For Each txt In Me.Controls
If Not IsMissing(ContainedIn) And Not ContainedIn Is Nothing Then
If txt.Container Is ContainedIn Then txt.Enabled = Status
End If
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Sub Command1_Click()
EnableDisableTextboxes False, Picture1
End Sub
Private Sub EnableDisableTextboxes(ByV
Dim txt As Control
For Each txt In Me.Controls
If txt.Container Is ContainedIn Then txt.Enabled = False
Next
End Sub
For example, just call as EnableDisableTextBoxes True,Picture1 to enable and ... False,Picture1 to disable
For example
Tim Cottee