Solved

URGENT:  Textboxes on a Picture Box

Posted on 2006-11-06
4
167 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

914 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

17 Experts available now in Live!

Get 1:1 Help Now