|
-
Feb 7th, 2007, 04:31 PM
#1
Thread Starter
Addicted Member
[RESOLVED] ForEach confusing me. Shows Captions instead of Names?
Hi,
I'm trying my luck with For Each control array logic and I'm confused as to why VB is returning the caption for the control, instead of the name(index)
Here is my code:
Code:
Dim daCtrl As Control
For Each daCtrl In frmMain.Controls
If TypeOf daCtrl Is ComboBox Then
msgbox daCtrl.Container
end if
Next
now the Container for the first 5 controls is a frame with the name of "Frame_Orders". The caption for that frame is "<Orders>"
The msgbox shows "<Orders>" But I am not asking for the Container.Caption value, I want the actual object name. It would seem almost obvious that VB would return the object name but apparently not. How do I get it to return the name instead of the caption?
Last edited by DssTrainer; Feb 7th, 2007 at 04:35 PM.
-
Feb 7th, 2007, 04:34 PM
#2
Re: ForEach confusing me. Shows Captions instead of Names?
It's because the default property for that control is caption not name
like:
for label the default property is caption
for textbox the default property is text
etc.
-
Feb 7th, 2007, 04:35 PM
#3
Thread Starter
Addicted Member
Re: ForEach confusing me. Shows Captions instead of Names?
hmm I tried
Code:
If TypeOf daCtrl Is ComboBox Then
msgbox daCtrl.Container.Name
end if
not expecting it to work.. but it did.
Why would it default to the caption? Also it defaults to the current text value of the combobox as well, instead of the name.
Odd but I guess resolved
-
Feb 7th, 2007, 04:36 PM
#4
Re: [RESOLVED] ForEach confusing me. Shows Captions instead of Names?
It is the behaviour of the vb. we cannot change that.
for combo box the default property is text property. that's why
-
Feb 8th, 2007, 07:32 AM
#5
Thread Starter
Addicted Member
Re: [RESOLVED] ForEach confusing me. Shows Captions instead of Names?
ya i saw your initial post after my second one.. Thanks for the clearing up!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|