I have a button that when clicked once it loads a picture in an image box. i want it to do that but when it is clicked twice i want it to goto a form 3. Can anyone right some code for this problem.
16 1296
try declaring a global variable ctr
then per click increment ctr then if ctr = 2
form3.show or the likes
that would work but i want people to be able to viw the image more than once. is it posible to do something like use something like the dbl click.
that would work but i want people to be able to viw the image more than once. is it posible to do something like use something like the dbl click.
The command button doesn't have a double-click event, but you might try simulating it. For example, when it is clicked, you could set a flag and start a timer. When the timer event fires (after half a second, for example) you can check whether the button was clicked again within that time. Also, in the click event, if the flag is already set, don't do anything except increment the "number of times clicked" counter.
could someone write the code for that i wouldn't know where to start with that one.
could someone write the code for that i wouldn't know where to start with that one.
If I can find the time, I'll have a shot at it when I get home (in a couple of hours).
However, if you think about it for a while you can probably work it out. It's not really a terribly complicated concept, just awkward to describe.
i don't know how to use the check function let alone the check function with a timer.
i don't know how to use the check function let alone the check function with a timer.
Well, I'm leaving work now. If someone else doesn't beat me to it, I'll give it a shot when I get home.
alrighty then. drive safe
alrighty then. drive safe
Hi again.
I'm home, and I've thrown together the first two options that came to mind, to produce the equivalent of a double-click on a command button. To use them, just create a new project, add a form, and place a timer and a command button on the form. Then go to the code window for that form, erase absolutely everything and paste in the following.
This is the one which I described earlier... - Option Explicit
-
DefLng A-Z
-
-
Dim Click_Count As Long
-
-
Private Sub Command1_Click()
-
Click_Count = Click_Count + 1
-
If Timer1.Enabled Then Exit Sub
-
Timer1.Enabled = True
-
End Sub
-
-
Private Sub Timer1_Timer()
-
If Click_Count > 1 Then
-
MsgBox "Hey, you clicked " & Format(Click_Count) & " times."
-
End If
-
Click_Count = 0
-
Timer1.Enabled = False
-
End Sub
This one works, but it's not very responsive, and doesn't really feel like a double-click. While writing it, I thought of a better way, which would respond immediately like a "real" double-click. Try this alternative... - Option Explicit
-
DefLng A-Z
-
-
Dim Click_Count As Long
-
-
Private Sub Command1_Click()
-
If Click_Count Then
-
' Consider this a double-click, and go do something.
-
MsgBox "Hey, you double-clicked the button!"
-
Click_Count = 0
-
Else
-
Click_Count = Click_Count + 1
-
Timer1.Enabled = True
-
End If
-
-
End Sub
-
-
Private Sub Timer1_Timer()
-
Click_Count = 0
-
Timer1.Enabled = False
-
End Sub
thanks that will help alot. i wont be able to try it until wednesday because that is when i goto my dad's house.
Oops! While I believe both those methods provide a double-click equivalent, I think I failed to handle the single-click. Here are modified versions of both which should work.
Note that the Interval property of the timer will affect the "double-click speed" - adjust it to suit yourself. I found 250 was a good setting. Method 1 - Option Explicit
-
DefLng A-Z
-
-
Dim Click_Count As Long
-
-
Private Sub Command1_Click()
-
Click_Count = Click_Count + 1
-
If Timer1.Enabled Then Exit Sub
-
Timer1.Enabled = True
-
End Sub
-
-
Private Sub Timer1_Timer()
-
If Click_Count > 1 Then
-
' Do your double-click processing here.
-
Debug.Print "Double-click"
-
Else
-
' Do your single-click processing here.
-
Debug.Print "Click"
-
End If
-
Click_Count = 0
-
Timer1.Enabled = False
-
End Sub
Method 2 - Option Explicit
-
DefLng A-Z
-
-
Dim Click_Count As Long
-
-
Private Sub Command1_Click()
-
If Click_Count Then
-
' Do your double-click processing here.
-
Debug.Print "Double-click"
-
Click_Count = 0
-
Else
-
Click_Count = Click_Count + 1
-
Timer1.Enabled = True
-
End If
-
-
End Sub
-
-
Private Sub Timer1_Timer()
-
Timer1.Enabled = False
-
If Click_Count = 1 Then
-
' Do your single-click processing here.
-
Debug.Print "Click"
-
End If
-
Click_Count = 0
-
End Sub
but i cant create a new project it needs to go in the middle of a 1/2 complete project. if you can wait till wednesday i can show you the code i have on the form already and you could right around it. till then i wont know if this code will work.:(
but i cant create a new project it needs to go in the middle of a 1/2 complete project. if you can wait till wednesday i can show you the code i have on the form already and you could right around it. till then i wont know if this code will work.:(
The ideal way to do this would be to create a new project and use it to try out these ideas. Once you understand what's going on, you can include it into your real code much more easily.
got it to work with my program. thanks so much
got it to work with my program. thanks so much
Glad we could help. :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Eric |
last post by:
I have the following function which creates buttons on Excel
commandbar. The problem i can't get the buttons to hook up to events.
For example, if i create four buttons only the fourth one fires...
|
by: Steve K |
last post by:
While reading "Eric Myer on CSS" I decided it was time to replace the
buttons on my page (which were graphics) with some CSS "buttons" but I
hit some snags.
The first set of buttons I replaced...
|
by: Trvl Orm |
last post by:
I am working with 2 frames, Left and Right and the main code is in the
left frame, which has been attached.
Can someone please help me with this code. I am new to JavaScript and
can't figure it...
|
by: Gequina |
last post by:
Something goes wrong in my script. I'm all new to it so i don't know
much yet.
I have a set of buttons. And when you click on either of them, the
background image will change. Only it's not...
|
by: MyNameIsnt |
last post by:
Can anyone tell me why, when I click on the buttons it register 2
characters on the display?
if you use the right mousebutton it works ok, but the buttons dont
flash??
it works fine without the...
|
by: momo |
last post by:
Hello all,
I need some help with radio buttons. This is what I have. I have 15 groups
of radio buttons and each group contains three radio buttons which non of
them are selected.
I need a way...
|
by: Bharat |
last post by:
Hi Folks,
Suppose I have two link button on a page (say lnkBtn1 and
lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically
created control. And On the click event of the lnkBtn2 I...
|
by: Edwinah63 |
last post by:
Hi everyone,
i was wondering if anyone else had observed this and if there is any
workaround or patch.
i have some screens (an mdi child forms) with the buttons &Add, &Edit,
&Save and E&xit,...
|
by: Learner |
last post by:
Hello,
I have two buttons on one of my VehicleDetails.aspx page. Obiviously
these two buttons takes the user to two different pages. Now my client
is interested in having a linkbutton instead of...
|
by: aboolamoola |
last post by:
hi, I recently started programing about a month ago. my teacher ask me to make a game. A connect 4 game. I try to make, but failed. I need help.
here is my code:
import java.awt.*;
import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |