View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default Gotta be some more Efficient code

Dim i As Integer
For i = 1 To 10
Controls("TextBox" & i).Visible = (Len(Controls("Label" & i).Caption) 0)
Next

I assume you don't need the Trim function because *you* will be creating the
captions and can avoid captions with only blank spaces ?

Greg


"Jennifer" wrote:

I have 10 text boxes is there a more efficient way to write this code.
Eventually there could be more textboxes and labels. Loop? Thank you so much.

If Len(Trim(Label1.Caption)) 0 Then
TextBox1.Visible = True
Else
TextBox1.Visible = False
End If
If Len(Trim(Label2.Caption)) 0 Then
TextBox2.Visible = True
Else
TextBox2.Visible = False
End If
--
Thank you,

Jennifer