Visual Basic Assignment #3
Question: Write a Program in VB to change the background/foreground colour of any of the controls of the form based on the colour selected from a list. Ans. 1. Open Visual Basic 6.0 Start→Programs/All Programs→Microsoft Visual Studio 6.0→Microsoft Visual Basic 6.0 Select Standard EXE → Open 2. Take one Combo Box(Combo1) 3. Double click on Combo1 4. Write the following Code- Private Sub Form_Load() Combo1.AddItem(“BLACK”) Combo1.AddItem(“BLUE”) Combo1.AddItem(“GREEN”) Combo1.AddItem(“CYAN”) Combo1.AddItem(“MEGENTA”) Combo1.AddItem(“VIOLET”) End Sub Private Sub Combo1_Change() Form1.BackColor=QBColor(Combo1.ListIndex) End Sub 5. Save the Project File→Save Project→Save in→ Select Desktop→xi16.frm→Save→xi16.vbp→Save 6. Run The Project Press F5