2017-05-04 124 views
0

我爲外部參數的每個變量分配了值,但我無法通過循環調用分配的值。使用For VB.Net中的每個循環打印每個變量的分配值

我現在使用的代碼僅供參考。

在此先感謝...

Module Module1 
    Public Int_Parameters() As String = {"Int_D1", _ 
          "Int_D2", _ 
          "Int_D3", _ 
          "Int_D4"} 

    Public Ext_Parameters() As Integer= {"Ext_D1", _ 
          "Ext_D2", _ 
          "Ext_D3", _ 
          "Ext_D4"} 
    Sub Assigning_Values() 
     Ext_D1 = 25 
     Ext_D2 = Ext_D1 + 25 
     Ext_D3 = Ext_D2 + 25 
     Ext_D4 = Ext_D3 + 25 
    End Sub 

    Sub Loop() 
     For Each Int_Parameter As String in Int_Parameters 
      For Each Ext_Parameter As String in Ext_Parameters 

      Int_Parameter = Ext_Parameter 'Ext_Parameter Value is 0 but i need the Assigned Values instead of 0 
      Next 
     Next 
    End Sub 
End Module 
+0

首先你應該在有關聲明中你的'In'關鍵字:'對於每個Int_Parameter作爲字符串在Int_Parameters'和同爲'對於每個Ext_Parameter作爲字符串在Ext_Parameters' – Mederic

+0

哎呀其實這是他們的原始代碼這個代碼是一種演示代碼,僅用於清除分配值的問題... – Josha

+0

好,以幫助您正確我們需要正確的代碼,如果有文字缺失我們不能幫你 – Mederic

回答

0
Module Module1 

Public Int_Parameters() As String = {"Int_D1", _ 
         "Int_D2", _ 
         "Int_D3", _ 
         "Int_D4"} 

Public Ext_D1, Ext_D2, Ext_D3, Ext_D4 As Integer 

Public List1 As New ArrayList 

Sub Assigning_Values() 

Ext_D1 = 25 
Ext_D2 = Ext_D1 + 25 
Ext_D3 = Ext_D2 + 25 
Ext_D4 = Ext_D3 + 25 

Dim Ext_Parameters() As Integer= {"Ext_D1", _ 
         "Ext_D2", _ 
         "Ext_D3", _ 
         "Ext_D4"} 

For Each Ext_Parameter As Integer in Ext_Parameters 
     List1.Add(Ext_Parameter) 
Next 

End Sub 

Sub Loop() 

For Each Int_Parameter As String in Int_Parameters 
    For Each Ext_Parameter As Integer in Ext_Parameters 

    Int_Parameter = Ext_Parameter 

    Next 
Next 

End Sub 

End Module 
相關問題