VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,768 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Sub CLEAR_ANY_GB_IN_FORM(GB As GroupBox, F As Form)
Dim FF As System.Windows.Forms.Form = F
Try
For Each TB As GroupBox In FF.Controls.OfType(Of GroupBox)()
If TB.Name = GB.Name Then
theses lines are working
For Each C As RichTextBox In GB.Controls.OfType(Of RichTextBox)() : C.Text = "" : Next
For Each C As DateTimePicker In GB.Controls.OfType(Of DateTimePicker)() : C.Text = "" : Next
For Each C As PictureBox In GB.Controls.OfType(Of PictureBox)() : C.Image = Nothing : Next
----------------------------------------------------------------------------------------------------------
For Each C As TextBox In GB.Controls.OfType(Of TextBox)() : C.Text = "" : Next
For Each C As ComboBox In GB.Controls.OfType(Of ComboBox)() : C.Text = "" : Next
these lines are not working
<text>' is not a member of '<visualstyleelement.textbox>
<text>' is not a member of '<visualstyleelement.combobox>
----------------------------------------------------------------------------------------------------------
End If
Next
Catch ex As Exception
End Try
I am using vs2022 enterprise latest update
Probably there is an unneeded statement:
Imports System.Windows.Forms.VisualStyles.VisualStyleElement.
Try removing it or clarify the situation.
By the way, why do you need the For Each TB and If statements?
I code it in different way and it worked thanks any way
Sub CLEAR_ANY_GB_IN_FORM(GB As GroupBox, F As Form)
Dim FF As System.Windows.Forms.Form = F
Try
For Each TB As GroupBox In FF.Controls.OfType(Of GroupBox)()
If TB.Name = GB.Name Then
For Each Ck As PictureBox In TB.Controls.OfType(Of PictureBox)() : Ck.BackgroundImage = Nothing : Next
For Each Ck As CheckBox In TB.Controls.OfType(Of CheckBox)() : Ck.CheckState = CheckState.Unchecked : Next
For Each C As Control In TB.Controls
Dim r = C.Controls.GetType
Dim xx = C.GetType()
If C.GetType.FullName = "System.Windows.Forms.Button" Then Continue For
If C.GetType.FullName = "System.Windows.Forms.Label" Then Continue For
If C.GetType.FullName = "System.Windows.Forms.CheckBox" Then Continue For
C.ResetText()
Next
End If
Next
Catch ex As Exception
End Try
End Sub ' ....................... CLEAR ANY GROUB BOX