• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Nesneleri temizlemede hata

  • Konbuyu başlatan Konbuyu başlatan ASMET67
  • Başlangıç tarihi Başlangıç tarihi

ASMET67

Altın Üye
Katılım
8 Haziran 2007
Mesajlar
410
Excel Vers. ve Dili
Excel 2016
For Each nesne1 In Controls
Tum Textbox ve comboboxları temizlemek için kullandığım kodda kırmızı ile yazdığım yerde hata vermektedir.
Hata mesajı:
Kod:
Compile Error :
Form Each control Varrable must be varrant or object
Kod:
Private Sub CommandButton5_Click()

Application.ScreenUpdating = False
Dim nesne As Integer
Dim nesne1 As Integer
'Dim nesne1 As Controls
Dim s1 As Worksheet
Set s1 = ThisWorkbook.Worksheets("Yardim_Bodrosu")
'On Error Resume Next
Application.ScreenUpdating = False
For Each nesne1 In Controls
If TypeName(nesne1) = "TextBox" Then ' NESNENIN ADI YAZILACAK
nesne1.Value = ""
End If
Next nesne1

For Each nesne In Controls
If TypeName(nesne) = "ComboBox" Then ' NESNENIN ADI YAZILACAK
nesne.Value = ""
End If
Next nesne
 
Dim nesne As Integer
Dim nesne1 As Integer

satırlarını

Dim nesne As Object
Dim nesne1 As Object

olarak değiştirin.
 
Merhaba,

Aşağıdaki şekilde bir denermisiniz?
Kod:
Private Sub CommandButton5_Click()
    Dim Nesne As Control
    
    For Each Nesne In Controls
        Select Case TypeName(Nesne)
            Case "TextBox", "ComboBox"
                Nesne = ""
        End Select
    Next
End Sub
 
teşekkürler.
 
Geri
Üst