0

只是试图解决一个问题,从基于另一个变量名的结构中获取特定的...

Sub Main()

    Dim Testing As Test
    ReDim Testing.A(15), Testing.B(13), Testing.C(10)

    Dim Letter As String = Console.ReadLine() 'User Inputs A, B Or C

    Testing.Letter(3) = "XXXXX" 'Selects the array of the letter the user has input from the Letter variable

End Sub

Structure Test
    <VBFixedString(5)> <VBFixedArray(15)> Dim A() As Integer
    <VBFixedString(5)> <VBFixedArray(13)> Dim B() As Integer
    <VBFixedString(5)> <VBFixedArray(10)> Dim C() As Integer
End Structure

感谢您的关注和建议的任何解决方案,非常感谢。

4

1 回答 1

0

我不太确定你在问什么,但也许你想要一个选择案例声明?

Sub Main()

    Dim Testing As Test
    ReDim Testing.A(15), Testing.B(13), Testing.C(10)

    Dim Letter As String = Console.ReadLine() 'User Inputs A, B Or C

    Select Case Letter.ToUpper
    Case "A" : Testing.A(3) = "XXXXX" 
    Case "B" : Testing.B(3) = "XXXXX" 
    Case "C" : Testing.C(3) = "XXXXX" 
    End Select

End Sub

你也可以使用反射...

于 2013-03-05T03:49:56.077 回答