Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on label name

Status
Not open for further replies.

frenchteck

IS-IT--Management
Feb 28, 2003
12
FR
This is my VB6 program, I know that it doesn't work but I would like too know the solution to put a caption into 100 labels without named all.
for i = 1 to 100
nom(i) = "label" & i
Next
for i = 1 to 100
nom(i).caption = i
Next
 
You could try something like this:

For i = 0 to frmForm.Controls.Count - 1
If Left(frmForm.Controls(i).Name, 5) = "Label" then
frmForm.Controls(i).Name = i
End If
End If

frmForm could be any form name

Hope it helps...
 
TomKane you cannot change the Name property of any control at run time.

frenchteck i am not able to understand your question clearly. but if i am right, you want to change the caption of all the labels on your form irrespective of their name.

See this code.

Dim ctl As Control
Dim i As Integer

For Each ctl In Me.Controls
If TypeOf ctl Is Label Then
ctl.Caption = i
i = i + 1
End If
Next

Bye.
Amol
 
Thank you for your help TomKane and bridamol.
I'm going to try your solution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top