• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Odd Or Even TextBox

delta

Member
my userform contain 30 TextBox there Name is TextBox 1 To TextBox 30.
i like Ode Number of TextBox (e.g.) TexBox1, TextBox3,TextBox5........
Textbox background Color is Black
and other is Even number TextBox Bcckground Color is White
i try by for loop the code i below what is wrong in code

Dim i As Integer
Dim z As Integer
z = 0
For i = 3 To 52
If i Mod 2 = 1 Then


Me.Controls("TextBox" & i).BackColor = RGB(0, 0, 0)

Next i
z = z + 1

Else



Me.Controls("TextBox" & i).BackColor = RGB(255, 255, 255)

End If

Next i

end sub
 
Hi, try following code
Code:
Dim i As Integer

For i = 1 To 30

    If i Mod 2 = 1 Then
  
  
        Controls("TextBox" & i).BackColor = RGB(0, 0, 0)
      
    Else
  
        Controls("TextBox" & i).BackColor = RGB(255, 255, 255)
      
    End If

Next i


End Sub
 
Back
Top