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

Add 1 to a Variable by pressing a Button in VB6

Moderator: dafunkymunky

Add 1 to a Variable by pressing a Button in VB6

Postby Blacktronics on Sun Mar 01, 2009 11:58 am

Hi there i making a file store with a password but it only counts 1 and stops i can click at the button like a ... :cry: i am using VB6
Code: Select all
Private Sub Command2_Click()

If Text1.Text = "9999999" Then
End
Else
Counter = Counter + 1
Text2.Text = (Counter)
End If
If Text2.Text = "5" Then
MsgBox "Account is Locked"
Text1.Enabled = False

End If
End Sub





Private Sub Form_Load()
Dim Count As Integer
Counter = 0#
End Sub

Hope u Can help :D :lol:
Blacktronics
 
Posts: 4
Joined: Sat Feb 14, 2009 10:16 pm

Re: Add 1 to a Variable by pressing a Button in VB6

Postby Suffer on Sun Mar 01, 2009 2:59 pm

Try this,but im not sure:

Counter = 0
If Text1.Text = "9999999" Then
End
Else
Counter = Counter + 1
Text2.Text = (Counter)
End If
If Text2.Text = "5" Then
MsgBox "Account is Locked"
Text1.Enabled = False

End If
End Sub
Suffer
100+ Club
 
Posts: 236
Joined: Tue Jan 20, 2009 6:34 am

Re: Add 1 to a Variable by pressing a Button in VB6

Postby Blacktronics on Sun Mar 01, 2009 3:43 pm

Nope Won´t work
Edit :
Any Other ideas?

Okay i Got it for every one who needs that the code below :
Code: Select all
Private Sub xpButton1_Click(Index As Integer)
If Text1.Text = "Password" Then
MsgBox "Acces Granted"

Else
MsgBox "Error : Wrong Passcode"
Label3.Caption = Val(Label3.Caption) - Val(1)
Text1.Text = ""

End If
If Label3.Caption = "0" Then
MsgBox "Password typed to often wrong passcode is locked"
Text1.Enabled = False

End If
End Sub


Be Sure that if u copy the code u change the Object names in the code
Blacktronics
 
Posts: 4
Joined: Sat Feb 14, 2009 10:16 pm

Re: Add 1 to a Variable by pressing a Button in VB6

Postby Keithuk on Sat Jul 11, 2009 1:55 pm

Blacktronics wrote:Hi there i making a file store with a password but it only counts 1 and stops i can click at the button like a ... :cry: i am using VB6
Code: Select all
Private Sub Command2_Click()

If Text1.Text = "9999999" Then
End
Else
Counter = Counter + 1
Text2.Text = (Counter)
End If
If Text2.Text = "5" Then
MsgBox "Account is Locked"
Text1.Enabled = False

End If
End Sub

Private Sub Form_Load()
Dim Count As Integer
Counter = 0#
End Sub



I know this is an old topic but no one has given a useful solution.

Well first of Blacktronics you aren't specifying the Counter variable in the correct place. Count is specified in Form_Load but its not needed so you can delete it.

Declare Dim Counter As Integer in the Declaration section of the code window. Thats right at the top under Option Explicit when you decide to use it.

You aren't using Option Explicit either because that would have told you that error. If you don't know what it does or how to set it up then just ask. :wink:
User avatar
Keithuk
 
Posts: 11
Joined: Fri Jun 01, 2007 11:16 am
Location: Staffordshire, England


Who is online

Users browsing this forum: No registered users and 4 guests