Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Creating a Dynamic Banner in Visual Basic.net

Author: DevASP
Download Source Code : 496_DynamicBanner.zip

In this article I will try to explain you how you can create Dynamic Banner that helps you to save any thing which is written in text box on your disk.

Open visual studio and create a new application using vb.net and drag a following control on the from 

  • Two textboxes
  • Four Labels
  • Five buttons
  • Color dialog control
  • Font Dialog Control 

Set the auto size property of any single to true on which you want to see preview

 

Now import the following

 

Imports System.Drawing

Imports System.Drawing.Imaging

 

Declare the following global variable to control the font, font size font color, image height and width file name and path

 

Private str As String = "Abdul Rehman"

Private FC As Color = Color.Red

Private BC As Color = Color.White

Private F As New Font("Times New Roman", 22)

Private V_height As Integer

Private V_width As Integer

Dim FileName As String

 

double click on the form and write the following code on the from load event

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      Button1.Text = "Font Color"

      Button2.Text = "Back Color"

      Button3.Text = "Font"

      Button4.Text = "Preview"

Button5.Text = "Save"

End Sub

 

Now double click on the font color button and write the following code in the button click event

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

ColorDialog1.ShowDialog()

FC = ColorDialog1.Color

End Sub

 

double click on the back color button and write the following code in the button click event

 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

ColorDialog1.ShowDialog()

BC = ColorDialog1.Color

End Sub

 

double click on the Font button and write the following code in the button click event

 

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

FontDialog1.ShowDialog()

F = FontDialog1.Font

End Sub

 

double click on the Preview button and write the following code in the button click event

 

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Label2.ForeColor = FC

Label2.BackColor = BC

Label2.Font = F

Label2.Text = TextBox1.Text

End Sub

 

double click on the Save button and write the following code in the button click event

 

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Label2.ForeColor = FC

      Label2.BackColor = BC

      Label2.Font = F

      Label2.Text = TextBox1.Text

 

      FileName = TextBox2.Text

      str = TextBox1.Text

      V_height = Label2.Height

      V_width = Label2.Width

 

      Dim objBitmap As New Bitmap(V_width, V_height)

      Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)

      Dim objPoint As New PointF(0.0F, 0.0F)

      Dim objBrushForeColor As New SolidBrush(FC)

 

      Dim objBrushBackColor As New SolidBrush(BC)

      objGraphics.FillRectangle(objBrushBackColor, 0, 0, V_width, V_height)

      objGraphics.DrawString(str, F, objBrushForeColor, objPoint)

      objBitmap.Save(FileName & ".JPG", ImageFormat.Jpeg)

End Sub

 

Article Comments
Pls help. Can't do the following?

Private FC As Color = Color.Red
Private BC As Color = Color.White
FileOpen(1, iniFileName, Microsoft.VisualBasic.OpenMode.Output, OpenAccess.Write)

WriteLine(1, BC)
WriteLine(1, FC)
FileClose(1)

Posted on 9/28/2010 12:02:38 PM by VJ

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Working With Mouse Events Using Visual Basic.Net

Disclaimer - Privacy
© 2002-2017 DevASP.net