Adding Controls to Frame Control

Loading Frames and trying to add Label controls

Page 1 of 1

3 Replies - 14844 Views - Last Post: 22 December 2008 - 07:06 AM Rate Topic: -----

#1 CAVU  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-December 08

Adding Controls to Frame Control

Posted 19 December 2008 - 01:55 PM


For Index = 1 To 35
Load Frame6(Index)
Load Label11(Index)
Form1.Controls.Add "VB.label", Label11(index), Frame6(Index)




Keep getting error that the Label11 control already exists
Is This A Good Question/Topic? 0
  • +

Replies To: Adding Controls to Frame Control

#2 tody4me  Icon User is offline

  • Banned
  • member icon

Reputation: 12
  • View blog
  • Posts: 1,398
  • Joined: 12-April 06

Re: Adding Controls to Frame Control

Posted 19 December 2008 - 02:40 PM

Rightly so, you're trying to add a new control called Label11 to the form 35 times. Look at the code closely and you'll see that also, unless you don't understand the language in which case I would recommend this site for beginning with VB.

This post has been edited by tody4me: 19 December 2008 - 02:40 PM

Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Adding Controls to Frame Control

Posted 19 December 2008 - 02:55 PM

Instead of having Label11(Index) why not just have the Label controls named with the index, something like this

Private Sub AddControlsToFrame()
	For Index = 1 To 35
		Load Frame(Index)
		Load Label(Index)
		Form1.Controls.Add "VB.label", Label11(index), Frame6(Index)
	Next
End Sub



Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#4 CAVU  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-December 08

Re: Adding Controls to Frame Control

Posted 22 December 2008 - 07:06 AM

View Posttody4me, on 19 Dec, 2008 - 01:40 PM, said:

Rightly so, you're trying to add a new control called Label11 to the form 35 times. Look at the code closely and you'll see that also, unless you don't understand the language in which case I would recommend this site for beginning with VB.


I swear I do not understand why people like you bother to respond to a post. Your responses are worthless and pointless with a tint of insult.



PsychoCoder,

Sorry, I don't see any difference in your code from mine. To use the Add method, you apparently have to have a unique name and it can not be a dynamic name.

I ended up just using the Set Label.container=Frame method.

Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1