By Kardi Teknomo, PhD.


< Previous | Next | VB Tutorial | Contents >

VB Color

  1. In the Toolbox, Right click and a pop up menu will be shown. You choose Components. A dialog window will appear. In the control Tab of the dialog, scroll down and find Microsoft Common Dialog Control. Check the Checkbox and press OK. See that the Common Dialog control is added to your toolbox
  2. Drag and drop the Common Dialog control into frmController.
  3. Add CommandButton inside Frame1 in the frmController, change the Name property into cmdColor. Change the Style property into Graphical. Change the BackColor property into any color you want. Delete the Caption property (make it empty).
  4. Double click the cmdColor and add code below
    Private Sub cmdColor_Click()
    CommonDialog1.ShowColor
    cmdColor.BackColor = CommonDialog1.color
    frmMap.MYCOLOR = cmdColor.BackColor
    End Sub

    VB Color

    Remember that we have declared public variable MYCOLOR in frmMap.

  5. Now run the program and draw manually. Change the color of the cmdColor in frmController and see what happen to the drawing color in frmMap.

< Previous | Next | VB Tutorial | Contents >

 

Rate this tutorial or give your comments about this tutorial

 

This tutorial is copyrighted.

Preferable reference for this tutorial is

Teknomo, Kardi. Visual Basic Tutorial . http:\\people.revoledu.com\kardi\ tutorial\VB