Skip to main content

AccessTr.neT


Buton İle Frame Backcolor Değiştirmek

Buton İle Frame Backcolor Değiştirmek

Çözüldü #1
Private Sub CommandButton1_Click()
    Dim ctl As Control
    For Each ctl In Me.Form
        If ctl.ControlType = acBoundObjectFrame Then
            If (ctl.Name = Me.TextBox1.Value) Then
                ctl.BackColor = GetHexColor(Me.TextBox2.Value)
            End If
        End If
    Next ctl
    Set ctl = Nothing
End Sub



bu kod ile Excelde
"Me.TextBox1.Value" değerine formdan manuel olarak "Frame8" 
"Me.TextBox2.Value" değerine formdan manuel olarak "#AAECDF"  yazacağım butona bastığımda rengi değişecek kodda 
"Me.Form" ve "acBoundObjectFrame" kalimelerinde hata veriyor nasıl yazmam lazım
@benbendedeilem
Son Düzenleme: 10/01/2020, 10:16, Düzenleyen: accessman.
Cevapla
#2
Me.Form --->  Me.Controls olacakmış
ama frame controlunun karşılığını bulamadım
acFrame olmalı diye düşünüyorum ama olmuyor
Cevapla
#3
şeyle bir kod var

Private Sub dene()
    Dim ctrl As Control
    For Each ctrl In Frame1.Controls
        If TypeOf ctrl Is MSForms.OptionButton Then
            If ctrl.Enabled = True Then
                MsgBox ctrl.Name & " is an enabled OptionButton with caption " & ctrl.Caption
            End If
        End If
    Next
End Sub
Cevapla
#4
böyle yazdım oldu

Private Sub CommandButton1_Click()
    changeColor Me.TextBox1.Value, Me.TextBox2.Value
End Sub

Private Sub changeColor(controlName As String, colorName As String)
    Dim ctrl As Control
    For Each ctrl In Me.Controls
        If TypeOf ctrl Is MSForms.Frame Then
            If ctrl.Enabled = True Then
                If (ctrl.Name = controlName) Then
                    ctrl.BackColor = GetHexColor(colorName)
                End If
            End If
        End If
    Next
End Sub
@benbendedeilem
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da
Task