title: Implementing a Variable in a Label Name in VB?
body: <p>I currently have a huge IF statement and want to minimize it as much as possible.</p>
  
  <p>I have a datagrid that i am populating from a SQL query and then from this datagrid i am passing the values into seperate labels.</p>
  
  <p>I am able to create a For Each Loop in which i cycle through the variables looking until a counter reaches 7. However the problem arises when i need to incremente the Label name values by one. Each time, so essentially i need to add a counter variable into the Label name.</p>
  
  <p>The code that i need to minimize is:</p>
  
  <pre><code>result73 = DataGridView1.Rows(0).Cells(0).Value.ToString
  result74 = DataGridView1.Rows(0).Cells(1).Value.ToString
  result75 = DataGridView1.Rows(1).Cells(0).Value.ToString
  result76 = DataGridView1.Rows(1).Cells(1).Value.ToString
  result77 = DataGridView1.Rows(2).Cells(0).Value.ToString
  result78 = DataGridView1.Rows(2).Cells(1).Value.ToString
  result79 = DataGridView1.Rows(3).Cells(0).Value.ToString
  result80 = DataGridView1.Rows(3).Cells(1).Value.ToString
  result81 = DataGridView1.Rows(4).Cells(0).Value.ToString
  result82 = DataGridView1.Rows(4).Cells(1).Value.ToString
  result83 = DataGridView1.Rows(5).Cells(0).Value.ToString
  result84 = DataGridView1.Rows(5).Cells(1).Value.ToString
  result85 = DataGridView1.Rows(6).Cells(0).Value.ToString
  result86 = DataGridView1.Rows(6).Cells(1).Value.ToString
  result87 = DataGridView1.Rows(7).Cells(0).Value.ToString
  result88 = DataGridView1.Rows(7).Cells(1).Value.ToString
  
  If result73 = "Monday" Then
      DaySalesLbl1.Text = result74
  ElseIf result73 = "Tuesday" Then
      DaySalesLbl2.Text = result74
  ElseIf result73 = "Wednesday" Then
      DaySalesLbl3.Text = result74
  ElseIf result73 = "Thursday" Then
      DaySalesLbl4.Text = result74
  ElseIf result73 = "Friday" Then
      DaySalesLbl5.Text = result74
  ElseIf result73 = "Saturday" Then
      DaySalesLbl6.Text = result74
  ElseIf result73 = "Sunday" Then
      DaySalesLbl7.Text = result74
  End If
  </code></pre>
  
  <p>This If Statement goes on for each variable that is declared above.</p>
  
  <p>The Loop I have created looks something like this:</p>
  
  <pre><code>Dim cou As Integer
  Dim n As Integer
  cou = 0
  n = 1
  Do Until result74 &lt;&gt; ""
      If result73 = cou Then
          DaySalesLbl +n = result74
      End If
      cou = cou + 1
      n = n + 1
  Loop
  </code></pre>
  
  <p>But the section <code>DaySalesLbl +n = result74</code> brings an Error because it looks for a generated method.</p>