Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleExperiment with shapes, colors, and fill styles
DescriptionThis example shows how to experiment with shapes, colors, and fill styles in Visual Basic 6.
Keywordsshape, FillColor, BackColor, border color
CategoriesGraphics, Controls
 
Thanks to Greg Doran.

This program uses ListBoxes to let the user select various shape properties. The ListBox event handlers set6 the properties of a Shape control. The following code shows how the program sets the Shape's BackColor.

 
'BACK GROUND COLOUR
Private Sub lstBackColor_Click()
    
    Dim i%                               'i, to hold the
        ' Index number
    Dim TheColourSelected&               'To hold the
        ' VBColour
    
    i% = Me.lstBackColor.ListIndex       'Get the ListBox
        ' Index number
                                         'that was clicked.
                                         ' (0....n)
    Select Case (i%)
    
        Case 0                           'If the ListBox
            ' Index number was
            TheColourSelected& = vbBlack ' 0, then the
                ' colour is Black
        Case 1
            TheColourSelected& = vbGreen
        Case 2
            TheColourSelected& = vbRed
        Case 3
            TheColourSelected& = vbYellow
        Case 4
            TheColourSelected& = vbBlue
    
    End Select
    Me.shpMain.BackColor = TheColourSelected&
    
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated