473,480 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to apply DrawLine in VB .NET?

Hello. I converted the project from VB6 in VB .NET 2003, however in the
following two procedures there are errors (in Help of VB .NET 2003 it is not
written, how to correct these errors):

' Plot the level curve F(X, Y) = level.
Private Sub PlotLevelCurve(ByVal pic As System.Windows.Forms.PictureBox, _
ByVal level As Single, ByVal xmin As Single, ByVal xmax As Single, _
ByVal ymin As Single, ByVal ymax As Single, Optional ByRef step_size _
As Single = 0.1, Optional ByVal start_x As Single = 1#, _
Optional ByVal start_y As Single = 1#, _
Optional ByVal tolerance As Single = 0.02)
#Const SHOW_TICS = False

Dim num_points As Short
Dim X0 As Single
Dim Y0 As Single
Dim X As Single
Dim Y As Single
Dim dx As Single
Dim dy As Single

' Find a point (X0, Y0) on the level curve.
FindPointOnCurve(X0, Y0, level, start_x, start_y, tolerance)

' Start here.
num_points = 1
' Start following the level curve.
X = X0
Y = Y0
Do
' Find the next point along the curve.
Gradient(X, Y, dx, dy)
If System.Math.Abs(dx) + System.Math.Abs(dy) < 0.001 Then Exit Do
X = X + dy * step_size
Y = Y - dx * step_size
FindPointOnCurve(X, Y, level, X, Y, tolerance)

' Draw to this point.
'UPGRADE_ISSUE: PictureBox method pic.Line was not upgraded. pic.Line
(X, Y)
#If SHOW_TICS Then
'UPGRADE_NOTE: #If #EndIf block was not upgraded because
'the expression SHOW_TICS did not evaluate to True
'or was not evaluated.

pic.Line -Step(dx * 0.1, dy * 0.1) 'Error.
pic.Line -Step(-dx * 0.1, -dy * 0.1) 'Error.
#End If
num_points = num_points + 1

' See if the point is outside the drawing area.
If X < xmin Or X > xmax Or Y < ymin Or Y > ymax Then Exit Do

' If we have gone at least 4 points, see if this
' is where we started.
If num_points >= 4 Then
If System.Math.Sqrt((X0 - X) * (X0 - X) + _
(Y0 - Y) * (Y0 - Y)) <= step_size * 1.1 Then
'UPGRADE_ISSUE: PictureBox method pic.Line was not upgraded.

pic.Line (X0, Y0) 'Error.
Exit Do
End If
End If
Loop
End Sub
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles MyBase.Load
Dim level As Short

Show()

'UPGRADE_ISSUE: PictureBox property Picture1.AutoRedraw was not
upgraded.
Picture1.AutoRedraw = True
'UPGRADE_ISSUE: PictureBox property Picture1.ScaleLeft was not upgraded.
Picture1.ScaleLeft = -2
'UPGRADE_ISSUE: PictureBox property Picture1.ScaleWidth was not upgraded.
Picture1.ScaleWidth = 4
'UPGRADE_ISSUE: PictureBox property Picture1.ScaleTop was not upgraded.
Picture1.ScaleTop = 2
'UPGRADE_ISSUE: PictureBox property Picture1.ScaleHeight was not
upgraded.
Picture1.ScaleHeight = -4

For level = -3 To 10
PlotLevelCurve(Picture1, level / 4, -4, 4, -4, 4, 0.05, 1, 1, 0.002)
Next level

' Get the second set of curves in the left peak.
For level = -3 To -1
PlotLevelCurve(Picture1, level / 4, -4, 4, -4, 4, 0.05, -1, 1, 0.002)
Next level
End Sub

The huge request: inform, please, how to correct these errors in two
procedures?

Beforehand many thanks for the answer, Dr. V.A. Zharkov. Moscow, Russia.

Nov 20 '05 #1
2 7506
Hi,

All drawing is done with the graphics class. Use the drawline method
to draw a line.
http://msdn.microsoft.com/library/de...wlinetopic.asp

Dim g as graphics = pic.CreateGraphics

Ken
------------------------
"Dr. Zharkov" <va************@mtu-net.ru> wrote in message
news:Ow**************@TK2MSFTNGP12.phx.gbl...
Hello. I converted the project from VB6 in VB .NET 2003, however in the
following two procedures there are errors (in Help of VB .NET 2003 it is not written, how to correct these errors):

' Plot the level curve F(X, Y) = level.
Private Sub PlotLevelCurve(ByVal pic As System.Windows.Forms.PictureBox, _
ByVal level As Single, ByVal xmin As Single, ByVal xmax As Single, _
ByVal ymin As Single, ByVal ymax As Single, Optional ByRef step_size _
As Single = 0.1, Optional ByVal start_x As Single = 1#, _
Optional ByVal start_y As Single = 1#, _
Optional ByVal tolerance As Single = 0.02)
#Const SHOW_TICS = False

Dim num_points As Short
Dim X0 As Single
Dim Y0 As Single
Dim X As Single
Dim Y As Single
Dim dx As Single
Dim dy As Single

' Find a point (X0, Y0) on the level curve.
FindPointOnCurve(X0, Y0, level, start_x, start_y, tolerance)

' Start here.
num_points = 1
' Start following the level curve.
X = X0
Y = Y0
Do
' Find the next point along the curve.
Gradient(X, Y, dx, dy)
If System.Math.Abs(dx) + System.Math.Abs(dy) < 0.001 Then Exit Do
X = X + dy * step_size
Y = Y - dx * step_size
FindPointOnCurve(X, Y, level, X, Y, tolerance)

' Draw to this point.
'UPGRADE_ISSUE: PictureBox method pic.Line was not upgraded. pic.Line
(X, Y)
#If SHOW_TICS Then
'UPGRADE_NOTE: #If #EndIf block was not upgraded because
'the expression SHOW_TICS did not evaluate to True
'or was not evaluated.

pic.Line -Step(dx * 0.1, dy * 0.1) 'Error.
pic.Line -Step(-dx * 0.1, -dy * 0.1) 'Error.
#End If
num_points = num_points + 1

' See if the point is outside the drawing area.
If X < xmin Or X > xmax Or Y < ymin Or Y > ymax Then Exit Do

' If we have gone at least 4 points, see if this
' is where we started.
If num_points >= 4 Then
If System.Math.Sqrt((X0 - X) * (X0 - X) + _
(Y0 - Y) * (Y0 - Y)) <= step_size * 1.1 Then
'UPGRADE_ISSUE: PictureBox method pic.Line was not upgraded.

pic.Line (X0, Y0) 'Error.
Exit Do
End If
End If
Loop
End Sub
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs
As System.EventArgs) Handles MyBase.Load
Dim level As Short

Show()

'UPGRADE_ISSUE: PictureBox property Picture1.AutoRedraw was not
upgraded.
Picture1.AutoRedraw = True
'UPGRADE_ISSUE: PictureBox property Picture1.ScaleLeft was not upgraded.
Picture1.ScaleLeft = -2
'UPGRADE_ISSUE: PictureBox property Picture1.ScaleWidth was not upgraded.
Picture1.ScaleWidth = 4
'UPGRADE_ISSUE: PictureBox property Picture1.ScaleTop was not upgraded.
Picture1.ScaleTop = 2
'UPGRADE_ISSUE: PictureBox property Picture1.ScaleHeight was not
upgraded.
Picture1.ScaleHeight = -4

For level = -3 To 10
PlotLevelCurve(Picture1, level / 4, -4, 4, -4, 4, 0.05, 1, 1, 0.002)
Next level

' Get the second set of curves in the left peak.
For level = -3 To -1
PlotLevelCurve(Picture1, level / 4, -4, 4, -4, 4, 0.05, -1, 1, 0.002)
Next level
End Sub

The huge request: inform, please, how to correct these errors in two
procedures?

Beforehand many thanks for the answer, Dr. V.A. Zharkov. Moscow, Russia.

Nov 20 '05 #2
Hi,
many thanks for answer, however it is present in Help of VB .NET 2003 and
for me is known.
Inform, please, information, which is absent in Help of VB .NET 2003,
namely, how to replace on VB .NET 2003 above mentioned lines of a code for
VB6:

pic.CurrentX = X0
pic.CurrentY = Y0
pic.Line (X, Y)
pic.Line -Step(dx * 0.1, dy * 0.1)
pic.Line -Step(-dx * 0.1, -dy * 0.1)
pic.Line (X0, Y0)

Picture1.AutoRedraw = True
Picture1.ScaleLeft = -2
Picture1.ScaleWidth = 4
Picture1.ScaleHeight = -4

Beforehand many thanks for the answer, Dr. V.A. Zharkov. Moscow, Russia.

Nov 20 '05 #3

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

Similar topics

4
41340
by: Jon Cosby | last post by:
I'm using this to draw rectangles in a PictureBox image. Not all of the rectangles are complete, and after drawing several, some of them start disapearing. What's the reason for this? Pen...
1
2711
by: Rich | last post by:
Hello, I am trying to draw a graph on a form. I can draw the box using drawline, and bars inside the box using drawrectangle, but when I try to draw a line inside the box the inner lines are...
4
5745
by: Smoke | last post by:
It is possible to draw a line on a control using AA? basically, i need the normal .DrawLine funcion but that support antia aliasing. is this possible? can somebody tellme how? Thanks for the...
2
1925
by: google_groups3 | last post by:
Hi, is it better practise to draw a line on my form using the Graphics.DrawLine command or should I use a label control instead? I am refering to overall speed of the form and amount of memory...
2
3018
by: John | last post by:
I created a number of pictureboxes in a panel, and want to draw lines in those pictureboxes but I cannot. Please see the following code and make corrections. Thanks. Private Sub...
0
1191
by: Lila Godel | last post by:
I am migrating my VB6 GoldMine add-ons to VB.NET to allow for enhancements. I have no problem getting text to print, but I cannot get the 4 PrintPage events that are needed to print a line to work....
2
2652
by: Stu | last post by:
Hi, Why does the code below only draw the last line of the loop? I was expecting this to draw 10 parallel lines. More to the piont....how do I get it to draw 10 parallel lines? Public...
3
3156
by: Ben Bush | last post by:
I had the following code and when I clicked the left mouse button one time. I got green line and the second click got a purple line and the green disappeared. I was confused by two questions:...
2
7151
by: intrepid_dw | last post by:
All I am writing a C# WinForms application which is giving me some problems. The application consists of a form containing an empty Tab control to which TabPages are added dynamically (at...
0
7037
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
6904
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
7032
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
7076
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...
1
6730
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...
0
2990
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...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
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 ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.