Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

URGENT:  Textboxes on a Picture Box

Posted on 2006-11-06
4
Medium Priority
?
175 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

886 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