How to make this "if" statement faster in VB Express?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Big P
    New Member
    • Jan 2011
    • 11

    How to make this "if" statement faster in VB Express?

    I have over 100 labels.
    My Question is:
    how to do the same without writing label1,label2,l abel3,label4 etc. till label 100.
    I need to save memory.
    tks for your help

    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    If TextBox1.Text = 1 Then
    Label1.Text = 4
    Label2.Text = 4
    Label3.Text = 4
    Label4.Text = 4
    
    End If
    End Sub
    Last edited by Niheel; Jan 27 '11, 09:38 PM.
  • Rodney Roe
    New Member
    • Oct 2010
    • 61

    #2
    I'm not sure if this works in vb express but it works in vb6 and it might be worth a try, or it might get you close to something else.

    Code:
    If TextBox1.Text = 1 then
      For i = 1 to 100
        Controls("Label" & cStr(i)) = 4
      next
    end if
    Hope it helps.

    Comment

    Working...