[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Command button

Posted on 2000-04-07
3
Medium Priority
?
171 Views
Last Modified: 2010-05-02
If I accidentally press any command buttons on a form two or three times, the calculated quantities should not change.  how can I do this?
0
Comment
Question by:fuad2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2693628
after the user clicks it once, disable the button until you want to allow the user to click it again.

command1.enabled = false
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2693638
or create a public boolean variable called answered or something and use it like this


Option Explicit
Dim answered as Boolean


Private Sub Form_Load()
answered = FALSE

Private Sub Command1_Click()
If answered = FALSE Then
   'do some calculations
   answered = TRUE
Else
   Exit Sub
End Sub
0
 
LVL 2

Accepted Solution

by:
ndnet earned 90 total points
ID: 2695392
I can see where this would be useful. The first answer given is better, since the user doesn't think that the button is still active.

If you use the second method, be sure to make edits to each textbox (or, more accurately, variable involved in the calculation) allow the command button to come back to life.

You could combine the two techniques  into your program like this:

Option Explicit
Dim answered as Boolean

Private Sub Textbox1_Change()
If answered = TRUE then
   'Allow calculations again
   answered = FALSE
   Command1.enabled = TRUE
End If

Private Sub Command1_Click()
If answered = FALSE Then
   'Insert happy calculations
   answered = TRUE
   Command1.enabled = FALSE
Else If answered = true then
Else
   msgbox "error"
End If
Exit Sub



You'll have to add the code from textbox1_change to all fields that change the data used by your calculations.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question