croag
asked on
Is this legal in VB.NET if not, why and how to solve it.
okay,...in the code for my main for which contains tcProfile. - Please read below
if tcProfile.tabPageCollectio n(tpAlerti nformation .Contains( grpAlert.C ontains(pn lEnableale rt.Contain s(cboEmail address.tx t)))) <> "" The
etc , etc, etc,
Now,...this isn't quite working...can someone tell me what's up? and I'm going about this wrong?
Thanks,
Thomas
if tcProfile.tabPageCollectio
etc , etc, etc,
Now,...this isn't quite working...can someone tell me what's up? and I'm going about this wrong?
Thanks,
Thomas
are you looking for the indexof() method which returns the index of a value here ? that would make more sense for use in the indexing of another collection.
ASKER
Hello,
Thanks for the read!...Well, I 'm just trying to write an IF statement in the load of the form...The thing is, the combo box that I'm trying to check, lives within panel which lives in a group which lives in a tabpage which belongs to a tabcontrol. Phew. Anyhelp is appreciated. Thanks!
Thanks for the read!...Well, I 'm just trying to write an IF statement in the load of the form...The thing is, the combo box that I'm trying to check, lives within panel which lives in a group which lives in a tabpage which belongs to a tabcontrol. Phew. Anyhelp is appreciated. Thanks!
could you test just
if (cboEmailaddress.text) <> "" Then
end if
We do not need to use contains to access it
the contains just used to go through the controls in the page
if (cboEmailaddress.text) <> "" Then
end if
We do not need to use contains to access it
the contains just used to go through the controls in the page
sorry for more ()
if cboEmailaddress.text <> "" Then
end if
if cboEmailaddress.text <> "" Then
end if
This is what I use to find a control recursively looking through other container controls:
Public Function FindControlByName(ByVal containerParent As Object, ByVal nameSearch As String) As Control
' Description:
' Starting with the top-level container, search through each control looking for a control
' with the specified name. If the current control has children controls, such as a GroupBox, then
' recursively call this routine to search for the control in each container.
' VB.NET is different in this regard from VB6, where Me.Controls in VB6 contained all the controls
' for the form, and in VB.NET it contains only the top-level controls.
Dim foundControl As Control
Try
For Each controlCurrent As Control In containerParent.Controls
If controlCurrent.Controls.Co unt > 0 Then
' The current control owns other controls, so search through the
' controls for that container for the specified control name.
foundControl = FindControlByName(controlC urrent, nameSearch)
End If
' Control not found from the container search?
If foundControl Is Nothing Then
' Control matched by name?
If controlCurrent.Name = nameSearch Then
' Return a reference to the control to the caller.
foundControl = controlCurrent
' Don't go any further, since the control was found.
Exit For
End If ' Control matched by name?
Else
' Don't go any further, since the control was found on the container.
Exit For
End If ' Control not found from the container search?
Next controlCurrent
Finally
End Try
Return foundControl
End Function 'FindControlByName'
Bob
Public Function FindControlByName(ByVal containerParent As Object, ByVal nameSearch As String) As Control
' Description:
' Starting with the top-level container, search through each control looking for a control
' with the specified name. If the current control has children controls, such as a GroupBox, then
' recursively call this routine to search for the control in each container.
' VB.NET is different in this regard from VB6, where Me.Controls in VB6 contained all the controls
' for the form, and in VB.NET it contains only the top-level controls.
Dim foundControl As Control
Try
For Each controlCurrent As Control In containerParent.Controls
If controlCurrent.Controls.Co
' The current control owns other controls, so search through the
' controls for that container for the specified control name.
foundControl = FindControlByName(controlC
End If
' Control not found from the container search?
If foundControl Is Nothing Then
' Control matched by name?
If controlCurrent.Name = nameSearch Then
' Return a reference to the control to the caller.
foundControl = controlCurrent
' Don't go any further, since the control was found.
Exit For
End If ' Control matched by name?
Else
' Don't go any further, since the control was found on the container.
Exit For
End If ' Control not found from the container search?
Next controlCurrent
Finally
End Try
Return foundControl
End Function 'FindControlByName'
Bob
ASKER
Thank you all for your input. Bob, I believe that you understand me the best. Is this function that you have written necessary for VB.NET only or was it neccessary for VB6 as well? If so, why? Also, Do you think you could show how you use your little function here in a piece of code...say..between form1 and form2, each containing a text box? Also, should that function have to be a module Thank you soooooooo much in advace.I've upped the points! Thanks!
In VB6, you didn't have the concept of containers having a Controls property. In VB.NET 2005, you will be able to reference a control by it's name:
GroupBox("textInput")
This isn't here yet, so this IMHO is necessary in VB.NET 2002 or 2003, since you can't reference controls by name.
You could have this as as shared function in a class module (like String.Format):
Public Class Utility
Public Shared Function FindControlByName
End Class
Call by Utility.FindControlByName( form1, "textInput")
Bob
GroupBox("textInput")
This isn't here yet, so this IMHO is necessary in VB.NET 2002 or 2003, since you can't reference controls by name.
You could have this as as shared function in a class module (like String.Format):
Public Class Utility
Public Shared Function FindControlByName
End Class
Call by Utility.FindControlByName(
Bob
ASKER
Maaan....thank you sooo much bob. You are alifesaver like none other. one last little thing...please? can I put pass that 'Call by Utility.FindControlName(fo rmname,con trolname)' into a different varibles in the load event on each form? if so. how..
Thank you soooo much...this has been great!!!!
Thank you soooo much...this has been great!!!!
ASKER
more points still for that last piece of info..then I'm all set I believe! Thanks!
ASKER
can I put pass that 'Call by Utility.FindControlName(fo rmname,con trolname)' above into a different varibles in the load event on each form so as to make limit the amount of typing I woud have to do (by not having to type Utility.FindControlName each time)? if so. how..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Bob