Fill colour

Program to colour given box background
Sol.
1. Start Visual Basic by clicking on the Start Button => All programs => Microsoft visual studio 6.0 => Microsoft Visual Basic 6.0
2.  Then you can see New project Dialogbox  select standard Exe project then click open button.

3. Now you have a Form Control. Change Form Caption property to “Fill the colors in the form’s background” ,Borderstyle to "1-fixed single" , Startupposition to “2-CenterScreen” and Set an Icon to the Form control by using Icon Property ( Click on --- ellipse button and select an icon from C:\Program Files\Microsoft Visual Studio\COMMON\Graphics\Icons\Writing\PEN02.ICO then click Open button).  
4. Add following controls to the form control
Sr. No
Control
Properties
Settings
1
Label1
Caption
Enter  the color
2
Textbox         
Name
Text
Font
Text1
blank
Times New Roman, 12 pts
3
Commandbutton
Caption
Default
&Color the form
True
4
Commandbutton
Caption
Cancel
&Exit
True
5
Image
Picture
Any picture (Only VB supported formats)
5. Click on the Command1  button and write codes in between Command1_Click  () event procedure.
Private Sub Command1_Click()

Dim scolor As String
scolor = UCase(Trim(Text1.Text))
Select Case scolor
Case Is = "RED"
Form1.BackColor = vbRed
Case Is = "BLUE"
Form1.BackColor = vbBlue
Case Is = "GREEN"
Form1.BackColor = vbGreen
Case Is = "YELLOW"
Form1.BackColor = vbYellow
Case Is = "BLACK"
Form1.BackColor = vbBlack
Case Is = "WHITE"
Form1.BackColor = vbWhite
Case Else
Text1.text = "Unknown color"
Form1.BackColor = vbWhite
End Select

End Sub
6. Click on the Command2  button and write codes in between Command2_Click  () event procedure.
Private Sub Command2_Click()
MsgBox ("Thanks for using my creative application")
End

End Sub

7. Now Start project using start  button on the standard toolbar or using F5 shortcut key on the keyboard.

Related Topics:
  1. Message
  2. Security check
  3. Arithmetic operator
  4. Fill Colour
  5. Popup menu
Download Project PDF