Hey everyone, can anyone help me out with a code that creates a program where a user can key in 3 coordinate points and when the click "Generate Triangle" button. the program automatically creates the program. Please help. Cheerz

Simple

Try this

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim b As New Bitmap(600, 400)
        Dim g As Graphics = Graphics.FromImage(b)


        Dim x1, x2, x3, y1, y2, y3 As Integer
        Dim s1() As String = Me.TextBox1.Text.Split(",")
        Dim s2() As String = Me.TextBox2.Text.Split(",")
        Dim s3() As String = Me.TextBox3.Text.Split(",")
        
        x1 = s1(0)
        y1 = s1(1)

        x2 = s2(0)
        y2 = s2(1)

        x3 = s3(0)
        y3 = s3(1)

        g.DrawLine(Pens.Black, x1, y1, x2, y2)
        g.DrawLine(Pens.Black, x2, y2, x3, y3)
        g.DrawLine(Pens.Black, x3, y3, x1, y1)

        Me.PictureBox1.Image = b
    End Sub

Simple

Try this

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim b As New Bitmap(600, 400)
        Dim g As Graphics = Graphics.FromImage(b)


        Dim x1, x2, x3, y1, y2, y3 As Integer
        Dim s1() As String = Me.TextBox1.Text.Split(",")
        Dim s2() As String = Me.TextBox2.Text.Split(",")
        Dim s3() As String = Me.TextBox3.Text.Split(",")
        
        x1 = s1(0)
        y1 = s1(1)

        x2 = s2(0)
        y2 = s2(1)

        x3 = s3(0)
        y3 = s3(1)

        g.DrawLine(Pens.Black, x1, y1, x2, y2)
        g.DrawLine(Pens.Black, x2, y2, x3, y3)
        g.DrawLine(Pens.Black, x3, y3, x1, y1)

        Me.PictureBox1.Image = b
    End Sub

Hey thanks, but it's not working...it's bringing this error...

Attachments project_prog1.jpg 53.54 KB

Simple

Try this

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim b As New Bitmap(600, 400)
        Dim g As Graphics = Graphics.FromImage(b)


        Dim x1, x2, x3, y1, y2, y3 As Integer
        Dim s1() As String = Me.TextBox1.Text.Split(",")
        Dim s2() As String = Me.TextBox2.Text.Split(",")
        Dim s3() As String = Me.TextBox3.Text.Split(",")
        
        x1 = s1(0)
        y1 = s1(1)

        x2 = s2(0)
        y2 = s2(1)

        x3 = s3(0)
        y3 = s3(1)

        g.DrawLine(Pens.Black, x1, y1, x2, y2)
        g.DrawLine(Pens.Black, x2, y2, x3, y3)
        g.DrawLine(Pens.Black, x3, y3, x1, y1)

        Me.PictureBox1.Image = b
    End Sub

Hey thanks, but it's not working...it's bringing this error...

Okay, take a look at my GUI for my project...i need the code for the "Generate Triangle" Button

Attachments project_prog2.jpg 42.4 KB
This article has been dead for over six months. Start a new discussion instead.