Results 1 to 4 of 4

Thread: [RESOLVED] Constant expression is required

  1. #1

    Thread Starter
    Hyperactive Member nickwrs's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta, Ga
    Posts
    398

    Resolved [RESOLVED] Constant expression is required

    Hi All,
    I'm trying to make following subroutine work. The problem is this part of the statement.

    Code:
    Optional ByVal _CurveColor As System.Drawing.Color = Color.Blue
    I've tried everything and can't seem to come up with a constant to use here. Any ideas?

    Code:
    Public Sub New(Optional ByVal _CurveName As String = "Curve", Optional ByVal _CurveColor As System.Drawing.Color = Color.Blue, Optional ByVal _UseY22 As Boolean = False)
            CurveName = _CurveName
            CurveColor = _CurveColor
            useY2 = _UseY22
    
        End Sub

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Constant expression is required

    Overload your method:
    Code:
        Public Sub New()
            'Defaults
            '_CurveName = "Curve"
            '_CurveColor = Blue
            '_UseY22 = False
            Me.New("Curve", Color.Blue, False)
        End Sub
    
        Public Sub New(ByVal _CurveName As String, ByVal _CurveColor As System.Drawing.Color, ByVal _UseY22 As Boolean)
            CurveName = _CurveName
            CurveColor = _CurveColor
            useY2 = _UseY22
        End Sub
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  3. #3
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Constant expression is required

    I hate Optional parameters and would also recommend wild bill's method.

  4. #4

    Thread Starter
    Hyperactive Member nickwrs's Avatar
    Join Date
    Jan 2000
    Location
    Atlanta, Ga
    Posts
    398

    Re: Constant expression is required

    That worked perfect. I like this so much better than optional parameters! Thanks

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