Multiple Variables

后端 未结 9 2005
不知归路
不知归路 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:42

    You can try like this:

    Dim aceVal, twoVal,fourVal,sevenVal, eightVal, nineVal, tenVal As Integer
    Dim threeVal As Integer =-1,fiveVal=-1,sixVal=-1
    

    alternatively follow this post: http://www.informit.com/library/content.aspx?b=Net_2003_21days&seqNum=95

    0 讨论(0)
  • 2020-12-19 05:43

    You can declare and asign the value using the constructor:

     Dim str1, str2, str3, str4 As New String("asdf")
     Dim int1, int2, int3, int4 As New Integer
    
    0 讨论(0)
  • 2020-12-19 05:46

    you can put it in List and use For Each method here is the code

    Dim aceVal, twoVal, threeVal, fourVal, fiveVal, sixVal, sevenVal, eightVal, nineVal, tenVal As Integer
    Dim var As New List(Of Integer) From {threeVal, fiveVal, sixVal} 'you can add more variable here
    For Each n As Integer In var
        n = -1
    Next
    
    0 讨论(0)
提交回复
热议问题