View Poll Results: Favorite VB editor

Voters
15. You may not vote on this poll
  • 4.0

    0 0%
  • 5.0

    2 13.33%
  • 6.0

    13 86.67%
Results 1 to 9 of 9

Thread: Question No One Can Answere

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Posts
    1

    Exclamation Question No One Can Answere

    I wan't to make a program were if you press all the buttons in any order the screen will close. I can get it to close If I go in order like 1,2,3 or if I end with three. I can't get it to work with just any order. So if you could tell me the code to do this I would be greatfull.

  2. #2
    Member FinnPanther's Avatar
    Join Date
    Jun 2001
    Location
    Finland
    Posts
    53

    Talking

    Simple: make a boolean for each button in your program.
    For example,

    Code:
    Dim blnButton1 As Boolean
    Dim blnButton2 As Boolean
    Dim blnButton3 As Boolean
    
    Private Sub Button1_Click(blaah blaah...)
       blnButton1 = True
    Call TestExit
    End Sub
    
    Private Sub Button2_Click(blaah blaah...)
       blnButton2 = True
    Call TestExit
    End Sub
    
    Private Sub Button3_Click(blaah blaah...)
       blnButton3 = True
    Call TestExit
    End Sub
    
    Private Sub TestExit()
      If blnButton1 _
      And blnButton2 _
      And blnButton3 _
      Then Unload MyForm
    End Sub
    Like that?
    -Panther

    Panther's HQ

  3. #3
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    Can you make all the buttons be part of one control array? If you do that you can make the code a lot smaller.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     TestExit Command1.TabIndex
    5. End Sub
    6.  
    7. Private Sub Command2_Click()
    8.     TestExit Command2.TabIndex
    9. End Sub
    10.  
    11. Private Sub Command3_Click()
    12.     TestExit Command3.TabIndex
    13. End Sub
    14.  
    15. Private Sub Command4_Click()
    16.     TestExit Command4.TabIndex
    17. End Sub
    18.  
    19. Private Sub TestExit(Identifier As Long)
    20.     Static AllClicked As New Collection
    21.     On Error Resume Next
    22.     AllClicked.Add Identifier, CStr(Identifier)
    23.     If AllClicked.Count = 4 Then Unload Me
    24. End Sub

    Change the 4 to however many command buttons you have.

  4. #4

    Thumbs down

    You must be a Visual Basic beginner...that thing is the easiest thing to do...come on man!
    Using Visual Studio 6 Enterprise
    ---------------------------------
    Everyone needs help at some point..
    This time or another.

  5. #5
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    Lay off "man," there are always going to be beginners--people worse than you, and there are always going to be experts--people better than you. So cool it. Anyways, you usually don't learn about collections until a little later on, and using a collection is probably the easiest way to do it.

  6. #6
    TheSarlacc
    Guest
    You must be a Visual Basic beginner...that thing is the easiest thing to do...come on man!
    leave him alone dickstick! when u began VB, u were a beginner and 100 bucks u asked some questions that u find now are a sinch. so dont be a hipocrit syn_bOy

  7. #7
    Addicted Member
    Join Date
    Jul 2000
    Location
    California
    Posts
    154

    Cool

    No need too get angry
    VB-World addict!

    All spelling errors are undocumented words!
    http://www.bells.f2s.com

  8. #8
    New Member
    Join Date
    Jul 2000
    Posts
    12
    Dim cmdCloseDim

    Private Sub cmdClose_Click(Index As Integer)
    For i = 0 To 10
    If i = Index Then
    cmdCloseDim = cmdCloseDim + 1
    cmdClose(Index).Enabled = False
    End If
    If cmdCloseDim = 11 Then
    End
    End If
    Next i
    End Sub
    Change the 10 to how many buttons you have, change tthe cmdClose to the name of the buttons; put them all in the same array

    It'll disable them as you click on them
    Last edited by Cheitan; Jul 12th, 2001 at 11:40 AM.
    Is that not the Beast you said you saw? The one from Hell, the one that strives to drown you in the deepest pits of darkness, the pits of insanity?

    My soul is resting yet my body alert; my instincts rule, my mind is shut; I am an animal, a beast on guard, hidden in my cave I cannot sleep, I just watch, watch your every movement, ready to strike at you when you expect it least. Look behind you, my friend, you might see my dead eyes staring through you, and you, too, might put your soul to rest, to be protected from the demon that's stalking you.

  9. #9
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    VB Code:
    1. Private Sub Command1_Click(Index As Integer)
    2.     Static AllClicked As New Collection
    3.     On Error Resume Next
    4.     AllClicked.Add Index, CStr(Index)
    5.     'Command1(Index).Enabled = False
    6.     If AllClicked.Count = 10 Then Unload Me
    7. End Sub
    Even shorter, uncomment that line if you want

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width