How to apply DrawLine in VB .NET?

D

Dr. Zharkov

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.
 
D

Dr. Zharkov

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top