It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

How to press buttons in a sequence?

Moderator: dafunkymunky

How to press buttons in a sequence?

Postby diablo947866 on Thu Sep 25, 2008 9:56 pm

Can anyone help me out i need to know how to write code to press 6 different buttons in order like a combination lock
diablo947866
 
Posts: 0
Joined: Thu Sep 25, 2008 9:50 pm

Postby chubzyko on Fri Sep 26, 2008 12:50 am

well, there are many ways on how you can do it.

here's a simple one that I had just created in vb6.

you need 1 txtbox there, 7 command buttons. the last command button is for the log in and you need 2 forms. just copy the code below.

Code: Select all
Option Explicit

Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim e As String
Dim f As String


Private Sub Command1_Click()
a = 1
Text1.Text = Text1.Text + a
End Sub

Private Sub Command2_Click()
b = 2
Text1.Text = Text1.Text + b
End Sub

Private Sub Command3_Click()
c = 3
Text1.Text = Text1.Text + c

End Sub

Private Sub Command4_Click()
d = 4
Text1.Text = Text1.Text + d
End Sub

Private Sub Command5_Click()
e = 5
Text1.Text = Text1.Text + e
End Sub

Private Sub Command6_Click()
f = 6
Text1.Text = Text1.Text + f
End Sub

Private Sub Command7_Click()
If Text1.Text = 654321 Then
'your code goes here, ex:
Form1.Hide
Form2.Show
Else
Text1.Text = ""
MsgBox "Access Denied"
End If

End Sub

Private Sub Form_Load()
Text1.Text = ""
Command1.Caption = 1
Command2.Caption = 2
Command3.Caption = 3
Command4.Caption = 4
Command5.Caption = 5
Command6.Caption = 6
Command7.Caption = "LOGIN"
Text1.Locked = True

End Sub

Private Sub Text1_Change()
Text1.MaxLength = 7
If Len(Trim(Text1.Text)) > 6 Then
MsgBox "You have reach the maximum digit to enter"
End If
End Sub
"Failure is the key to success, so try and try until you succeed."
User avatar
chubzyko
100+ Club
 
Posts: 104
Joined: Wed Jul 30, 2008 10:48 pm
Location: Marikina City, Philippines


Who is online

Users browsing this forum: No registered users and 7 guests