Results 1 to 4 of 4

Thread: Function

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2013
    Location
    Assam
    Posts
    1

    Function

    How to pass objects like shape as a parameters to a function in VB6 plz explain with example.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Function

    Try something like this:
    Code:
    Option Explicit
    
    Private Enum ShapeStyles
        Rectangle = VBRUN.ShapeConstants.vbShapeRectangle
        Square = VBRUN.ShapeConstants.vbShapeSquare
        Oval = VBRUN.ShapeConstants.vbShapeOval
        [Circle] = VBRUN.ShapeConstants.vbShapeCircle
        [Rounded Rectangle] = VBRUN.ShapeConstants.vbShapeRoundedRectangle
        [Rounded Square] = VBRUN.ShapeConstants.vbShapeRoundedSquare
    End Enum
    
    Private Sub Form_Load()
        Shape1.Shape = ShapeStyles.[Rounded Rectangle]
    End Sub
    
    Private Sub Command1_Click()
        ChangeShape Shape1, ShapeStyles.Oval
    End Sub
    
    Private Sub ChangeShape(shp As Shape, newShape As Integer)
        Shape1.Shape = newShape
    End Sub

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Function

    Why would you define an Enum that is the same as an existing built-in Enum? And then pass such values as Integers instead of as the Enum type?

  4. #4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width