Code for Implementing Graphics in VB.NET


Here there is a well description about the code for program for implementing graphics in VB.NET

PROGRAM CODE FOR IMPLEMENTING GRAPHICS IN VB.NET




Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class Form1
Dim a, b, c, d As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
Dim g As Drawing.Graphics
g = Me.CreateGraphics
Dim p As New Pen(Color.Chocolate)
g.Drawline(p, a, b, c, d)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
Dim g As Drawing.Graphics
g = Me.CreateGraphics
Dim p As New Pen(Color.Chocolate)
g.DrawRectangle(p, a, b, c, d)
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
Dim g As Drawing.Graphics
g = Me.CreateGraphics
Dim p As New Pen(Color.Chocolate)
g.DrawEllipse(p, a, b, c, d)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
Dim g As Drawing.Graphics
g = Me.CreateGraphics
Dim p As New Pen(Color.DarkTurquoise)
g.DrawRectangle(p, a, b, c, d)
Dim r As Rectangle
r = New Rectangle(a, b, c, d)
Dim brush As LinearGradientBrush
brush = New Drawing2D.LinearGradientBrush(r, Color.Yellow, Color.Red, Drawing2D.LinearGradientMode.ForwardDiagonal)
g.FillRectangle(brush, r)
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
Dim g As Drawing.Graphics
g = Me.CreateGraphics
Dim p As New Pen(Color.Brown)
g.DrawEllipse(p, a, b, c, d)

Dim r As Rectangle
r = New Rectangle(a, b, c, d)
Dim brush As LinearGradientBrush
brush = New Drawing2D.LinearGradientBrush(r, Color.DarkViolet, Color.DeepSkyBlue, Drawing2D.LinearGradientMode.ForwardDiagonal)
g.FillEllipse(brush, r)
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
Dim g As Drawing.Graphics
g = Me.CreateGraphics
Dim p As New Pen(Color.Brown)
g.DrawRectangle(p, a, b, c, d)

Dim r As Rectangle
r = New Rectangle(a, b, c, d)
Dim brush As HatchBrush
brush = New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.DarkOrchid, Color.DarkSeaGreen)
g.FillRectangle(brush, r)
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
a = TextBox1.Text
b = TextBox2.Text
c = TextBox3.Text
d = TextBox4.Text
Dim g As Drawing.Graphics
g = Me.CreateGraphics
Dim r As Rectangle
r = New Rectangle(a, b, c, d)
Dim p As New Pen(Color.Black)
g.DrawRectangle(p, a, b, c, d)
p.DashStyle = DashStyle.DashDotDot

End Sub
End Class


Comments

Author: Reets12 Feb 2010 Member Level: Gold   Points : 1

This code snippet is not working

Reet



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: