enable forms/buttons using VB


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: enable forms/buttons using VB

  1. #1
    Join Date
    Sep 2006
    Posts
    1

    Cool enable forms/buttons using VB

    I know this may sound amatuer and silly to some but I need some help. I have a gentleman that helps me from time to time and is teachign me Vb at work but I'm working on a project at home and cant contact him. Please help me.

    I want to create a database control form that will enable or disable different forms or buttons etc in my database. I plan on trying to install this in multiple locations and some need some controls others dont. So any controls or forms that arent needed can be hidden by simply selecting a check box to enable and deselect to hide it.

    Lets use a small example:

    Main menu: 3 buttons

    1st is a IN button opening the In form

    2nd is an Out button opening an out button

    3rd being an control form (this is where things would eb enabled or disabled)

    If I added two check boxes to the Control Form one name In and one named Out and if they are checked then on the main menu they would be visible, if they are unchecked they would not be visible.

    Can someone help me with this code please I can see it in my head but cant get it right.

    I know it would be I think...

    IN = true then
    ???????.visible

  2. #2
    Join Date
    Apr 2004
    Location
    New York City
    Posts
    538
    I don't understand what you mean when you say the buttons will "enable or disable different forms or buttons etc in my database." Databases don't have forms or buttons; they have data, tables, and fields...

    If I understand your question, you will have multiple forms in your application, and one form will control the visibility of the controls in the other form?

    If that is what you want, you just need to reference the buttons on the other form in the Click() event of the checkbox on your control form.

    So if form1 is the name of the form you will control, then, on the "Control Form", in VB (I am assuming this is VB.NET), double-click the checkbox. That will open the code window, and will create the code to handle the click event. It will look like this, if we name the checkbox "CheckBoxIN":
    Code:
    Private Sub CheckBoxIN_CheckedChanged(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles CheckBoxIN.CheckedChanged
    
    End Sub
    In between the 2 lines, you would do something like this:
    (assuming the button on form1 is named "cmdIN")

    Code:
    If CheckBoxIN.Checked = True Then
           form1.cmdIN.Visible = True
    Else
           form1.cmdIN.Visible = False
    End If
    Or, even better and shorter, do this:
    Code:
    form1.cmdIN.Visible = CheckBoxIN.Checked

    That should take care of it.

    HTH,

    -Andrew

Similar Threads

  1. Told you so.... C# replacing VB
    By Bob in forum .NET
    Replies: 44
    Last Post: 06-06-2008, 04:39 AM
  2. re: moving from VB to C# -- more reasons
    By Jeff Johnson in forum .NET
    Replies: 6
    Last Post: 01-18-2007, 07:44 AM
  3. .NET vs. Enterprise Java: Who's Got Better Security?
    By Glen Kunene in forum Talk to the Editors
    Replies: 17
    Last Post: 03-23-2002, 12:43 AM
  4. Re: Writer's Uninformed Statements
    By Rich in forum .NET
    Replies: 38
    Last Post: 09-07-2001, 05:55 PM
  5. VB 6 does not get error from RAISERROR in SQL stored procdure
    By Allison Boughton in forum VB Classic
    Replies: 6
    Last Post: 03-05-2001, 12:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center