Using Color As Optional Parameter In a function within a class

后端 未结 4 1318
轮回少年
轮回少年 2021-01-11 16:09

How can I declare an optional color parameter in some function or sub, as if I do that in the normal way (I mean to give some default color for that optional parameter) as t

4条回答
  •  忘掉有多难
    2021-01-11 16:45

    You could overload the method

    ''' 
    ''' requires two parameters
    ''' 
    ''' an integer
    ''' a color
    ''' 
    Private Sub Test(a As Integer, c As Color)
        'Your function
    End Sub
    
    ''' 
    ''' one parameter, uses default color of black
    ''' 
    ''' an integer
    ''' 
    Private Sub Test(a As Integer)
        Test(a, Color.Black)
    End Sub
    

提交回复
热议问题