Solved

URGENT:  Textboxes on a Picture Box

Posted on 2006-11-06
4
166 Views
Last Modified: 2010-04-30
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
0
Comment
Question by:dwe0608
4 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 17880294
Hi dwe0608,

Private Sub Command1_Click()
    EnableDisableTextboxes False, Picture1
End Sub

Private Sub EnableDisableTextboxes(ByVal Status As Boolean, ByRef ContainedIn As PictureBox)
    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
0
 
LVL 1

Author Comment

by:dwe0608
ID: 17880353
And if I wanted to enable all textboxes - the following code marked by  ?? would be helpful

Private Sub EnableDisableTextboxes(ByVal 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
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 17880452
Tim already give you the solution, the only thing he should use status to set the enabled flag

ie.


Private Sub EnableDisableTextboxes(ByVal 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
0
 
LVL 11

Accepted Solution

by:
Dany Balian earned 500 total points
ID: 17887701
i got what u want darrin...

here's your code

Private Sub EnableDisableTextboxes(ByVal Status As Boolean, Optional ByRef ContainedIn As PictureBox = Nothing)
    Dim txt As Control
    For Each txt In Me.Controls
        If ContainedIn Is Nothing Then
            txt.Enabled = Status
        Else
            If txt.Container Is ContainedIn Then txt.Enabled = Status Else txt.Enabled = Not Status
        End If
    Next
End Sub

if call the function in the following way:

to disable textboxes contained in a specific picture box u call:
EnableDisableTextboxes False, Picture1 'false because u want to disable them, if u want to re-enable them u just set this to true

if u want to disable all textboxes u just call
EnableDisableTextboxes False 'or True to re-enable all textboxes on your form

hope this helps

cheers,

Dan

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now