473,320 Members | 2,145 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,320 software developers and data experts.

How to include a button click procedure in an if then statement?

Im writing an if then statement and i want it to say something like this:

If intx = 1 and btn.click = true then
'the rest of code
end if

But obviously "btn.click" isnt a real command. Any ideas?
Oct 8 '11 #1
2 1754
!NoItAll
297 100+
To start I don't think you can do this. click is an asynchronous event and your If statement is synchronous. What I'm really saying here is that any goal of the above code is invalid so I would ask you to explain what it is you want to do.
If you wanted to know if a particular button had been clicked when this If statement runs, then that is easy. Simply create a global boolean flag such as

bMyButtonWasClicked

In the button_click event set this value to TRUE and when your If Statement gets called it will be true only if the button event occurred. Be sure to set it to false inside your If code so it isn't just always true(unless thats what you want).

The other way is to reverse the logic and put your if statement inside the button_click event. If the IF statement runs then you know that the button_click event was called.

Expand|Select|Wrap|Line Numbers
  1. Private Sub button1_Click(sender As System.Object, e As System.EventArgs) Handles button1.Click
  2.     If intx = 1 then
  3.      'the rest of code
  4.     end if 
  5.  
  6. End Sub
  7.  
Oct 8 '11 #2
kadghar
1,295 Expert 1GB
Or you can use an STATE BUTTON and since the button is an object and its state is an attribute you can use it wherever you want.
Oct 11 '11 #3

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

Similar topics

3
by: VbUser25 | last post by:
hi.. i have a form i accept some user inputs in the form. there is a link on the form from where i open the excel file in the same browser (not in a new page...simply using a href. i am also...
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...
1
by: Martin | last post by:
Hi, I have produced a custom server control that simple outputs a row of 26 buttons, one button for each letter of the english alphabet. now what I would like to do is catch the button click...
20
by: anthonymelillo | last post by:
Is there a way to call a button click event from somewhere else ? I have a text box where I would like to call a button click event when a user presses enter in the text box. Can I do this ?...
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...
0
by: PointyPointy | last post by:
Hey, I'm hoping some can help me out with a small problem I'm having. I've got two frames - Frame1 and Frame2. Both have aspx pages (Primarily VB) loaded in them but to keep this explination...
8
by: Learner | last post by:
Hello, I converted a VS 2003 project to VS 2005. It works perfectly alright in VS 2003 but when I try running in VS 2005 I got strange thing going on. The code (my button click event ) runs...
1
by: Kuldeep | last post by:
Hello All, Visual Studio 2005 ASP.NET 2.0 C#.NET 2.0 I have an application which has a Button click event procedure as given below. protected void btn_Click(object sender, EventArgs e)
2
by: Randy | last post by:
I have a form on which various controls are added dynamically depending on actions of the user. One of these actions allows the user to click a delete button that will remove various other...
2
by: Max2006 | last post by:
Hi, I have a simple form with a button on it. After a button click postback, anytime user press F5 (browser page refresh), the button's OnClick event handler is called again without the button...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.