Option Explicit On
Option Strict On
Imports System.Drawing
Public Class Form2
Dim oPen As Pen = New Pen(Color.Black, 4)
Dim oPic As Graphics
Dim cptos() As PointF
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
oPic = PictureBox1.CreateGraphics
Call Datos(cptos)
oPic.DrawPolygon(oPen, cptos)
End Sub
Private Sub Datos(ByRef cptos() As PointF) 'notar el uso de ByRef
Dim D0 As Integer = 40 ' Lado 1
Dim D1 As Integer = 30 ' Lado 2
Dim D2 As Integer = 50 ' Lado 3
Dim Px1 As Double = 0 : Dim Py1 As Double = 0
Dim Px2 As Double = D0 : Dim Py2 As Double = 0
Dim Px3 As Double = Px1 : Dim Py3 As Double = Py2 + D1
Dim P1 As New PointF(CSng(Px1), CSng(Py1))
Dim P2 As New PointF(CSng(Px2), CSng(Py2))
Dim P3 As New PointF(CSng(Px3), CSng(Py3))
Dim cptos2() As PointF = {P1, P2, P3} 'aqui me daba error si no indicaba Dim
cptos = cptos2
End Sub
End Class