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

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

x1 = Val(s1(0))
        y1 = Val(s1(1))
 
        x2 = Val(s2(0))
        y2 = Val(s2(1))
 
        x3 = Val(s3(0))
        y3 = Val(s3(1))

now try this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.