Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Clicking Command Button Twice...


Reply
 
Thread Tools Display Modes
  #1  
Old 10-09-2006, 04:36 PM
s3cur17y s3cur17y is offline
Newcomer
 
Join Date: Aug 2003
Posts: 11
Default Clicking Command Button Twice...


Hi, I am looking for a way to see if a user has clicked a command button twice, and then if so I would like to disable the command button..

Private Sub btn_equipment_Click(Index As Integer)
Dim tmpFlash, tmpSmoke As String
tmpFlash = 0 'Flash click counter starts at zero.
tmpSmoke = 0 'Smoke click counter starts at zero.

If btn_equipment(2) Then 'If btn_equipment(2) is clicked then.
tmpFlash = tmpFlash + 1 'Add 1 to tmpFlash
If tmpFlash >= 2 Then 'Check to see if command button has been clicked twice.
btn_equipment(2).Enabled = False 'Disable command button.
Else
btn_equipment(2).Enabled = True 'Enable command button
End If
Debug.Print
End If

Debug.Print btn_equipment(Index).Tag
End Sub
Reply With Quote
  #2  
Old 10-09-2006, 04:38 PM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

Static tmpFlash As String, tmpSmoke As String
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #3  
Old 10-09-2006, 04:40 PM
s3cur17y s3cur17y is offline
Newcomer
 
Join Date: Aug 2003
Posts: 11
Default

Quote:
Originally Posted by reboot
Static tmpFlash As String, tmpSmoke As String
I tryed doing that but it is not working...

Private Sub btn_equipment_Click(Index As Integer)
Static tmpFlash, tmpSmoke As String
tmpFlash = 0 'Flash click counter starts at zero.
tmpSmoke = 0 'Smoke click counter starts at zero.



and also I am getting an error on this line...

If btn_equipment(2) Then 'If btn_equipment(2) is clicked then.




ALSO it is not adding 1 to tmpFlash
Reply With Quote
  #4  
Old 10-09-2006, 04:41 PM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

ok well, if you set them back to 0 each time, how is it ever going to get to 2?
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #5  
Old 10-09-2006, 04:42 PM
s3cur17y s3cur17y is offline
Newcomer
 
Join Date: Aug 2003
Posts: 11
Default

Quote:
Originally Posted by reboot
ok well, if you set them back to 0 each time, how is it ever going to get to 2?

How do i make it so it does not reset to zero?
Reply With Quote
  #6  
Old 10-09-2006, 04:53 PM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

Oh I don't know... maybe take out the tmpFlash = 0 line?
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #7  
Old 10-09-2006, 06:51 PM
4x2y 4x2y is offline
Contributor
 
Join Date: Sep 2005
Posts: 565
Default

you can rewrite the code as follow
Code:
Private Sub btn_equipment_Click(Index As Integer) Static tmpFlash As Integer Static tmpSmoke As Integer If Index = 2 Then tmpFlash = (tmpFlash + 1) Mod 2 btn_equipment(2).Enabled = tmpFlash End If End Sub

the command button disabled when clicked towice even if the period between the 2 clicks is too long, but if you want it work as double click behaviour, this is another story
__________________
Visit my site
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->