Multiple Variables

后端 未结 9 2049
不知归路
不知归路 2020-12-19 04:49

Is there a way to give a value to multiple variables (integers in this case), instead of all at once?

For instance, I have Dim aceVal, twoVal, threeVal, fourVa

9条回答
  •  臣服心动
    2020-12-19 05:25

    I know this is an old thread, however I've just run into a similar issue myself - here's how I did it (I am only dealing with 4 values

    Private Sub SetFalse(ByRef first As Boolean, Optional ByRef second As Boolean = False, Optional ByRef third As Boolean = False, Optional ByRef fourth As Boolean = False)
        first = False
        second = False
        third = False
        fourth = False
    End Sub
    

    this can be easily adapted, by making the first variable the required value (this code also looks a bit daft because I have to provide a default which can only be true or false, but obviously with integers or something it looks more meaningful.)

提交回复
热议问题