473,804 Members | 3,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why Isn't My Mouse Click Code Working

I have the following code and it returns the x and y coordinates in the text
box, but when I click the mouse on say 362,61 does not bring up form2.Any
suggestions?
Thanks,
Jerry

Private Sub PictureBox1_Mou seClick(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles PictureBox1.Mou seClick
Dim mouseX As Integer = e.X
Dim mouseY As Integer = e.Y
TextBox1.Text = e.X
TextBox2.Text = e.Y
If TextBox1.Text = 341 553 And TextBox2.Text = 22 148 Then
Form2.Show()
Me.Hide()
End If
End Sub

May 20 '07 #1
3 1817
What are you trying to do with this line of code:

If TextBox1.Text = 341 553 And TextBox2.Text = 22 148 Then
...............
End If

IMO, a code like that should not get complied, but, well, it is VB and it
simply does too much on user's behalf sometimes, so that user was fooled on
what is wrong. In this case, if VB does not do the implicit type conversion,
then you cannot compare TextBox.Text to a non-string value, so that you know
what is wrong.

Since the code seems compiled, then VB actually does is, first compares
341>553, it gets "False", then VB compares TextBox1.Text to False, the
result is False; the same for the next part. The overall result for the
"If..." statement would be False, so, you would never get Form2.Show() to
run.

VB's such behaviour IMO, is doing too much on user's behalf, that is one
reason one should give up VB.NET for C#.
"Jerry" <Je***@discussi ons.microsoft.c omwrote in message
news:7A******** *************** ***********@mic rosoft.com...
>I have the following code and it returns the x and y coordinates in the
text
box, but when I click the mouse on say 362,61 does not bring up form2.Any
suggestions?
Thanks,
Jerry

Private Sub PictureBox1_Mou seClick(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles PictureBox1.Mou seClick
Dim mouseX As Integer = e.X
Dim mouseY As Integer = e.Y
TextBox1.Text = e.X
TextBox2.Text = e.Y
If TextBox1.Text = 341 553 And TextBox2.Text = 22 148 Then
Form2.Show()
Me.Hide()
End If
End Sub

May 20 '07 #2
What my ultimate goal is to have my mouse click on a part of the picture box
top left location 341,22/bottom left location 341,48/top right location
553,22/bottom right location 553,148 and to have the program detect if the
mouse click was anywhere in the square, if so load form2
Thanks,
Jerry

"Norman Yuan" wrote:
What are you trying to do with this line of code:

If TextBox1.Text = 341 553 And TextBox2.Text = 22 148 Then
...............
End If

IMO, a code like that should not get complied, but, well, it is VB and it
simply does too much on user's behalf sometimes, so that user was fooled on
what is wrong. In this case, if VB does not do the implicit type conversion,
then you cannot compare TextBox.Text to a non-string value, so that you know
what is wrong.

Since the code seems compiled, then VB actually does is, first compares
341>553, it gets "False", then VB compares TextBox1.Text to False, the
result is False; the same for the next part. The overall result for the
"If..." statement would be False, so, you would never get Form2.Show() to
run.

VB's such behaviour IMO, is doing too much on user's behalf, that is one
reason one should give up VB.NET for C#.
"Jerry" <Je***@discussi ons.microsoft.c omwrote in message
news:7A******** *************** ***********@mic rosoft.com...
I have the following code and it returns the x and y coordinates in the
text
box, but when I click the mouse on say 362,61 does not bring up form2.Any
suggestions?
Thanks,
Jerry

Private Sub PictureBox1_Mou seClick(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles PictureBox1.Mou seClick
Dim mouseX As Integer = e.X
Dim mouseY As Integer = e.Y
TextBox1.Text = e.X
TextBox2.Text = e.Y
If TextBox1.Text = 341 553 And TextBox2.Text = 22 148 Then
Form2.Show()
Me.Hide()
End If
End Sub


May 20 '07 #3
So, the code wuold look like
Private Sub PictureBox1_Mou seClick(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles PictureBox1.Mou seClick

If e.X >= 341 AND e.X <= 553 And e.Y >= 22 AND e.Y <= 148 Then

TextBox1.Text=e .X.ToString()
TextBox2.Text=e .Y.ToString()

Form2.Show()
Me.Hide()

End If
End Sub
"Jerry" <Je***@discussi ons.microsoft.c omwrote in message
news:A6******** *************** ***********@mic rosoft.com...
What my ultimate goal is to have my mouse click on a part of the picture
box
top left location 341,22/bottom left location 341,48/top right location
553,22/bottom right location 553,148 and to have the program detect if the
mouse click was anywhere in the square, if so load form2
Thanks,
Jerry

"Norman Yuan" wrote:
>What are you trying to do with this line of code:

If TextBox1.Text = 341 553 And TextBox2.Text = 22 148 Then
...............
End If

IMO, a code like that should not get complied, but, well, it is VB and it
simply does too much on user's behalf sometimes, so that user was fooled
on
what is wrong. In this case, if VB does not do the implicit type
conversion,
then you cannot compare TextBox.Text to a non-string value, so that you
know
what is wrong.

Since the code seems compiled, then VB actually does is, first compares
341>553, it gets "False", then VB compares TextBox1.Text to False, the
result is False; the same for the next part. The overall result for the
"If..." statement would be False, so, you would never get Form2.Show() to
run.

VB's such behaviour IMO, is doing too much on user's behalf, that is one
reason one should give up VB.NET for C#.
"Jerry" <Je***@discussi ons.microsoft.c omwrote in message
news:7A******* *************** ************@mi crosoft.com...
>I have the following code and it returns the x and y coordinates in the
text
box, but when I click the mouse on say 362,61 does not bring up
form2.Any
suggestions?
Thanks,
Jerry

Private Sub PictureBox1_Mou seClick(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles PictureBox1.Mou seClick
Dim mouseX As Integer = e.X
Dim mouseY As Integer = e.Y
TextBox1.Text = e.X
TextBox2.Text = e.Y
If TextBox1.Text = 341 553 And TextBox2.Text = 22 148 Then
Form2.Show()
Me.Hide()
End If
End Sub



May 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
17314
by: Csaba2000 | last post by:
I have set onmousedown to change the cursor, but this setting is ignored (IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the mouse button is released. On Opera 7.01, the setting seems to be ignored completely, even when I try with window.setTimeout. So my two questions are: (1) Most important: Is there anything I can do so that I don't have to wait for the next mouse event before the cursor gets repainted. (2) Why...
9
22756
by: punkin | last post by:
I am trying to catch mouse position on the entire screen by dynamically generating mouse click event at every 100 ms. My code only works for IEs but not any Netscape or Gecko-based browsers. The following are the problems and I hope that there is someone who can enlighten me or give me some pointers. Also, my testing code is attached at the end. And please don't ask me why I am doing this - it is one of functional requirements by all...
4
3667
by: masantha wee | last post by:
Hi all, I am using Firefox and embedding Javascript in html. I understand that we can use mouse events by coding them in the body of html (by creating a button or anything and by adding in the events in the <img> tag). <input id="StdDev Value" name="StdDevButton" type="button" value="Standard Deviation Value" onclick="readStdDevValue()"/>
3
4490
by: Rick Strahl [MVP] | last post by:
I'm working on an app that's using the WebBrowser control. I got the control working fine, hooking to the document object. But I've run into a major issue with hooking the Document events. Whenever I hook any of the HTMLDocumnetEvent2_Event events like this: HTMLDocumentEvents2_Event DocEvents = this.Browser.Document as HTMLDocumentEvents2_Event ; DocEvents.oncontextmenu += new...
2
10101
by: KarenP | last post by:
In my Windows Forms application, while executing a process that takes some time, I am changing the cursor to the hourglass by setting Cursor.Current = Cursors.WaitCursor. This is working just fine, except that any mouse events generated during this wait period (such as clicking on a button, etc.), get processed once the processing is complete. For example, while waiting for my task to complete, I click on a button (even though the...
0
3169
by: 6tc1 | last post by:
Hi all, I've got a UserControl that contains a few PictureBox objects. If I click on outside of the Picture in the UserControl, the scrolling with the mouse button works - however, no amount of clicking on the PictureBox objects will get that scrolling working. However, after I click on outside of the PictureBox object, then click as many times as I like on the PictureBox the scrolling with the mouse wheel continues to work. I found...
3
2079
by: jcrouse | last post by:
I have created a form designer type application (with a lot of you peoples helpJ). It has label controls that are draggable at runtime. The user is also allowed to change some properties such as forecolor, backcolor and font. The labels also are rotatable and the text can also be flipped 180 degrees (the flipped text part is still being worked on). I have one context menu for all 30 labels that allows for the property changes to the labels....
3
3771
by: Morten Snedker | last post by:
If I have a number of random applications open, move the mouse cursor to a given position and do a click, the application gets the focus. That is what this simple code should illustrate: Dim pt As Point Dim wnd As IntPtr Const WM_LBUTTONUP = &H202 '//LButton up Const WM_LBUTTONDOWN = &H201 '//LButton down
4
7521
by: flplini | last post by:
I want to ask how to use C++ to simulate the mouse control? ex:Let the mouse double-click the left key functions,thanks!
0
10578
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10077
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5522
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.