473,378 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Button and If Statement

63
How can I write an if -statement where a condition is made true when a button is not clicked?

i.e. If cmdButton_Click = False Then
...
Dec 5 '07 #1
10 23943
muddasirmunir
284 100+
i donot think you can use
Expand|Select|Wrap|Line Numbers
  1. If cmdButton_Click = False Then 
but this task can be achived in ohther way
make a check box
by default it is unchecke (false)
and when button is clicked give its value ture
now use condintion
Expand|Select|Wrap|Line Numbers
  1.  if checkbox.value=false then
which is now become equal to
Expand|Select|Wrap|Line Numbers
  1. If cmdButton_Click = False Then
i think you understand



How can I write an if -statement where a condition is made true when a button is not clicked?

i.e. If cmdButton_Click = False Then
...
Dec 5 '07 #2
lee123
556 512MB
but whats the rest of the code this is an IF statement is there a false to this? like:

Expand|Select|Wrap|Line Numbers
  1. If checkbox.value = false then
  2.   ' do something?
  3. else
  4.  ' Not do something?
  5.  
  6. End IF
lee123
Dec 5 '07 #3
muddasirmunir
284 100+
plz clarify , i did not understand what did you mean by
"what is the rest of the code"

if you explian what you actually want to do may be we can help
you better


but whats the rest of the code this is an IF statement is there a false to this? like:

Expand|Select|Wrap|Line Numbers
  1. If checkbox.value = false then
  2. ' do something?
  3. else
  4. ' Not do something?
  5.  
  6. End IF
lee123
Dec 6 '07 #4
Dököll
2,364 Expert 2GB
plz clarify , i did not understand what did you mean by
"what is the rest of the code"

if you explian what you actually want to do may be we can help
you better
Hello, muddasirmunir!

Expand|Select|Wrap|Line Numbers
  1.  
  2. .Enabled may also work for you
  3.  
  4. Private Sub...
  5.  
  6. If cmdMyButton.Enabled = False Then
  7. MsgBox ("Hey, what gives!")
  8. Else
  9. MsgBox  ("That's what I am talking about!")
  10. End If
  11.  
  12.  
MsgBox can be reoplaced by what you need, I believe previous OP attempted to relay similar info

Open up another form rather than "MsgBox ("That's what I am talking about!")"

Have fun!

Dököll
Dec 6 '07 #5
lee123
556 512MB
yea i was responding to MIZIAQ question usually there is more to an if statement:

example:

they would want a checkbox to do something or a textbox to do something but this " if statement " doesn't have any of them

lee123
Dec 6 '07 #6
debasisdas
8,127 Expert 4TB
The best thing to do is to use a checkbox instead of a command button and change its style. so it behaves like a toggle button. Then you need to use the value property.
Dec 7 '07 #7
vdraceil
236 100+
Write the code of IF CLICKED CONDITION under command buttons click event(this event is triggered immediately when the botton is clicked) and write the ELSE CONDITION under forms mousemove event(when the mouse pointer is over the form there is no chance for the button getting clicked).
Dec 9 '07 #8
9815402440
180 100+
hi
if i am not wrong then you are trying to know whether a button has been clicked or not ( from a group of buttons). if no button has been clicked then you want to do something. if this is the case then you have two ways out. first is to use index array. in this case single click event will occur for all buttons,
e.g.

private sub command_click(index as integer)
'set value of variable here. and then chek the value in some other place to process.
end sub

other ways is declare a booleean vaiable at form level. in the form_load event (or anywhere you deem fit.) set it to false. set its value in the click event of each button to true. if the its value is false then no button is clicked.

hope i have not mis-interprated your question

regards
manpreet singh dhillon hoshiarpur
Dec 9 '07 #9
Torgg
41
MiziaQ

I think debasisdas has the best advice. Use a checkbox and change the "Style" property to graphical, this will make the checkbox appear to be a button. Then use the value property of the checkbox to see if it has been clicked. Like so...

Expand|Select|Wrap|Line Numbers
  1. If Check1.Value = 0 Then
  2.    ' Do Something
  3. Else
  4.    ' Do Something Else
  5. End If
Torgg
Dec 11 '07 #10
jamesd0142
469 256MB
Apologies if this is repeating something above, I couldn't be bothered to read it all...

Why not say :

dim a as string = "0"

then a = "1" in the button.

So you can now say:
if a = 1 then... (it's been pressed)
else
.........(it hasn't been pressed)
Dec 11 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: JCE | last post by:
I need to programmatically invoke an asp:Button click event from a javascript function. The page containing the script and the button is the HTML page associated with a WebUserControl-derived...
7
by: code100579 | last post by:
Hi there, sorry if this is a really simple question. I need to write code for: If a button is pushed and then one variety of other buttons is pushed then certain options on the program will...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
2
by: bay_dar | last post by:
Hi, I have an internal ASP.NET application that I'm are using to send e-mails out based on a single milepost or milepost range entered. I'm trying to do two things when a user clicks on the...
2
by: rookiejavadude | last post by:
I'm have most of my java script done but can not figure out how to add a few buttons. I need to add a delete and add buttong to my existing java program. Not sure were to add it on how. Can anyone...
7
by: magmike | last post by:
I currently have a button once clicked, invokes the following: If Address_Select = -1 Then Forms!ProspectForm!Address = End If However, there are 11 other fields in the subform that i'd like...
1
by: esteban40oz | last post by:
I have 9 buttons on my form. Button1, Button2, Button3, etc I want to create an array to access the value of each of them. Dim buttonArray() As Button = {Button1, Button2, Button3, Button4,...
7
by: =?Utf-8?B?Sm9zZXBo?= | last post by:
I would like to know how to implement several Radiobuttons using the Switch statement instead of If/Else conditional statement. For instance, if I have the following: if (RadioButton1.Checked =...
18
Jerry Maiapu
by: Jerry Maiapu | last post by:
I am trying to create a simple clock in clock out (timesheet) in ms access. I have two tables (tblnames for staff names and tbldates for clocking times). tblnames has 2 fields namely...
3
by: Bob Smith | last post by:
I have to come up with a user authenication page the logs the user in and also gives them access to do the right things. without using server side scripting. Just javacript and access. I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.