473,396 Members | 1,987 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,396 software developers and data experts.

Plotting Graph

37
Hi there,
I seem to face some problems with multiple click event. When i click plotButton, it should plot a cross. For example if user select 250Hz, it will plot a cross at 250Hz. x and y are the pixel values to draw the cross. When the user select a different frequency (eg. 500Hz) and click plotButton again, the cross for the 250Hz will disappear. So how do i make it stay? I think it has got something to do with the plotButton click event.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Audiogram_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
  2.   If BIEMaskingMachine.freqTrackBar.Value = 250 Then
  3.     If BIEMaskingMachine.count = -10 Then
  4.       x = 80
  5.       y = 50
  6.       G.DrawLine(Bluepen, (x - 5), (y - 5), (x + 5), (y + 5)) 'drawing 'x'
  7.       G.DrawLine(Bluepen, (x + 5), (y - 5), (x - 5), (y + 5))
  8.       xpoints(0) = G
  9.     End If
  10.  
  11.     If BIEMaskingMachine.freqTrackBar.Value = 500 Then
  12.       If BIEMaskingMachine.toneLabel.Text = "-10dB" Then
  13.         x = 120
  14.         y = 50
  15.         H.DrawLine(Bluepen, (x - 5), (y - 5), (x + 5), (y + 5)) 'drawing 'x'
  16.         H.DrawLine(Bluepen, (x + 5), (y - 5), (x - 5), (y + 5))
  17.         xplotted500 = H
  18.       End If
  19. End Sub
The plotButton is in a different form. This is the code for the plotButton.

Expand|Select|Wrap|Line Numbers
  1. Private Sub plotButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles plotButton.Click
  2.  
  3.   'Audiogram.ShowDialog()
  4.   Audiogram.Show()
  5.  
  6. End Sub
Jul 23 '07 #1
3 1903
Killer42
8,435 Expert 8TB
Hi tigger.

I haven't even tried to follow the code yet (assuming I could, since I'm a VB6 developer, not VB.Net). But after tidying up the indenting (sorry, I just like it nice and symmetrical), I have to ask - does the VB.Net compiler really allow you to get away with wildly unbalanced IF...End If structures like that? If so, frankly I'm appalled.

And I suspect that may be the source of any problems. For instance, the test for freqTrackBar.Value = 500 is dependent on the truth of freqTrackBar.Value = 250. Unless I've just missed something in between which changes the value, the second test can never be true.
Jul 23 '07 #2
tigger
37
Hi tigger.

I haven't even tried to follow the code yet (assuming I could, since I'm a VB6 developer, not VB.Net). But after tidying up the indenting (sorry, I just like it nice and symmetrical), I have to ask - does the VB.Net compiler really allow you to get away with wildly unbalanced IF...End If structures like that? If so, frankly I'm appalled.

And I suspect that may be the source of any problems. For instance, the test for freqTrackBar.Value = 500 is dependent on the truth of freqTrackBar.Value = 250. Unless I've just missed something in between which changes the value, the second test can never be true.

Sorry i actually posted only part of the codes. If not, it's quite long.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Audiogram_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
  2.   If BIEMaskingMachine.freqTrackBar.Value = 250 Then
  3.     If BIEMaskingMachine.count = -10 Then
  4.       x = 80
  5.       y = 50
  6.       G.DrawLine(Bluepen, (x - 5), (y - 5), (x + 5), (y + 5)) 'drawing 'x'
  7.       G.DrawLine(Bluepen, (x + 5), (y - 5), (x - 5), (y + 5))
  8.       xpoints(0) = G
  9.     End If
  10. End If
  11.  
  12.     If BIEMaskingMachine.freqTrackBar.Value = 500 Then
  13.       If BIEMaskingMachine.toneLabel.Text = "-10dB" Then
  14.         x = 120
  15.         y = 50
  16.         H.DrawLine(Bluepen, (x - 5), (y - 5), (x + 5), (y + 5)) 'drawing 'x'
  17.         H.DrawLine(Bluepen, (x + 5), (y - 5), (x - 5), (y + 5))
  18.         xplotted500 = H
  19.       End If
  20. End If
  21. End Sub
Jul 23 '07 #3
Killer42
8,435 Expert 8TB
I'd be more inclined to suspect the AutoRedraw setting, or whatever the equivalent is in VB.Net.

Not too sure about VB.Net, but I believe the general way that painting a window (a "window" can be a control such as a picturebox) works is that Windows (or VB) either stores a permanent copy to be thrown back on screen whenever the control needs to be repainted, or it leaves it up to the code in the Paint event procedure to draw it.

So if Windows is calling this Paint code of yours each time the window (control) needs to be repainted, then I guess you're only going to get whatever your routine says to paint.

Perhaps you ought to have a look on the web for a tutorial covering how to produce graphics in VB.Net. VB does make things relatively simple, but sometimes it's not quite as simple as it seems.
Jul 23 '07 #4

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

Similar topics

2
by: KevinGPO | last post by:
I am making a monitor program for the PC. My monitor program will grab statistics about CPU and memory every 1 or 5 seconds. Then I want to store this data so I have a history and hence be able to...
11
by: Chapman | last post by:
Is it possible to plot the graph as an output of my program in C? It can be a simple graph as quadratic curves for example or a correlation between 2 variables only. Thanks
1
by: wayne | last post by:
i want to plot a line graph. The values that I obtain are the RGB value of a TIFF image. i m plotting RGB values vs value(1,2,3..) so when generated the RGB values, there will b a column of values...
7
by: diffuser78 | last post by:
My python program spits lot of data. I take that data and plot graphs using OfficeOrg spredsheet. I want to automate this task as this takes so much of time. I have some questions. 1. Which is...
3
by: 9966 | last post by:
Greetings, I'm currently having problem in plotting a simple graph in C++. I learned that we can actually use koolplot to do it. My question is whether it is possible to plot, let's say the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
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,...
0
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...
0
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,...
0
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...
0
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 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.