View Poll Results: Favorite VB editor
- Voters
- 15. You may not vote on this poll
-
Jul 5th, 2001, 02:07 PM
#1
Thread Starter
New Member
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.
-
Jul 5th, 2001, 02:36 PM
#2
Member
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?
-
Jul 5th, 2001, 04:51 PM
#3
Fanatic Member
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:
Option Explicit
Private Sub Command1_Click()
TestExit Command1.TabIndex
End Sub
Private Sub Command2_Click()
TestExit Command2.TabIndex
End Sub
Private Sub Command3_Click()
TestExit Command3.TabIndex
End Sub
Private Sub Command4_Click()
TestExit Command4.TabIndex
End Sub
Private Sub TestExit(Identifier As Long)
Static AllClicked As New Collection
On Error Resume Next
AllClicked.Add Identifier, CStr(Identifier)
If AllClicked.Count = 4 Then Unload Me
End Sub
Change the 4 to however many command buttons you have.
-
Jul 6th, 2001, 12:46 PM
#4
Member
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.
-
Jul 6th, 2001, 12:55 PM
#5
Fanatic Member
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.
-
Jul 8th, 2001, 09:25 PM
#6
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
-
Jul 9th, 2001, 03:06 PM
#7
Addicted Member
No need too get angry
-
Jul 12th, 2001, 11:36 AM
#8
New Member
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.
-
Jul 12th, 2001, 11:41 AM
#9
Fanatic Member
VB Code:
Private Sub Command1_Click(Index As Integer)
Static AllClicked As New Collection
On Error Resume Next
AllClicked.Add Index, CStr(Index)
'Command1(Index).Enabled = False
If AllClicked.Count = 10 Then Unload Me
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|