The StopWatch object does not have a name property. Please do not post duplicate threads.
Reverend Jim
Carpe per diem
3,596 posts since Aug 2010
Reputation Points: 561
Solved Threads: 446
Skill Endorsements: 32
Other thread
Dim NextPanelStopwatch As New Stopwatch
This thread
Dim Stopwatch As New Stopwatch ' <-- How can I assign the name [Stopwatch1]?
Both threads create a StopWatch object at runtime and in the last thread I explained that there is no Name property of the StopWatch object. How is that not a duplicate thread? You need to pay attention to the answer or state the question more clearly. You said How can I assign the name [Stopwatch1]?. What do you want to assign that name to?
If I am missing something obvious here I apologize but it's 02:25 AM and I'm more than a little tired from not sleeping.
Reverend Jim
Carpe per diem
3,596 posts since Aug 2010
Reputation Points: 561
Solved Threads: 446
Skill Endorsements: 32
That's clearer. I thought you were still trying to assign a name to the StopWatch object. If you are creating all of the panels at the same time (ie in a loop inside a code block, then you can just use a local variable. If you are doing the creation at different times (ie different calls to a sub or function) then you will have to make the variable global. For the local case you get
for i = 1 to 5
dim NextPanel as New Panel
NextPanel.Name = "Panel" & i.Tostring()
Me.Controls.Add(NextPanel)
next
for the global case you get
Public Form Form1
Private panelnum As Integer = 0
.
.
.
Private Sub MySub()
for i = 1 to 5
panelnum += 1
dim NextPanel as New Panel
NextPanel.Name = "Panel" & panelnum.Tostring()
Me.Controls.Add(NextPanel)
next
Is that more what you had in mind?
Reverend Jim
Carpe per diem
3,596 posts since Aug 2010
Reputation Points: 561
Solved Threads: 446
Skill Endorsements: 32
No problem. Glad we got it straightened out.
Reverend Jim
Carpe per diem
3,596 posts since Aug 2010
Reputation Points: 561
Solved Threads: 446
Skill Endorsements: 32
Question Answered as of 3 Months Ago by
Reverend Jim