why is .text is not a member of textbox control vs2022

ASHRAF ABUSHANAB 0 Reputation points
2023-01-21T15:11:47.76+00:00
 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 
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,668 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Viorel 114.7K Reputation points
    2023-01-21T16:18:12.8266667+00:00

    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?

    0 comments No comments

  2. ASHRAF ABUSHANAB 0 Reputation points
    2023-01-22T02:14:43.84+00:00
     
    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
    
    0 comments No comments