• DİKKAT

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

Optionbutton Seçilen Textbox Eğer Doğru Cevap ise Renk Değiştirsin

Katılım
3 Haziran 2017
Mesajlar
797
Excel Vers. ve Dili
2007, 32
Arkadaşlar,

Ekteki resimden daha iyi anlaşılacağı üzere, Optionbutton seçilen Textbox eğer doğru cevap ise renk değiştirmesini istiyorum. Doğru cevap 6 seçenekteki Textbox7'de yer alıyor. Textbox numaraları 2'den 7'ye kadar. Sınavı Değerlendir Butonu'na basıldığında rengin değişmesini istiyorum.
 

Ekli dosyalar

  • 2.jpg
    2.jpg
    8.6 KB · Görüntüleme: 9
Son düzenleme:
Kod:
Private Sub CommandButton19_Click()
'1
If TextBox2.Text = TextBox7.Text And OptionButton1 = True Then
TextBox2.BackColor = &HFF8080
Else
TextBox2.BackColor = &H80000005
End If
'2
If TextBox3.Text = TextBox7.Text And OptionButton2 = True Then
TextBox3.BackColor = &HFF8080
Else
End If
TextBox3.BackColor = &H80000005
'3
If TextBox4.Text = TextBox7.Text And OptionButton3 = True Then
TextBox4.BackColor = &HFF8080
Else
TextBox4.BackColor = &H80000005
End If
'4
If TextBox5.Text = TextBox7.Text And OptionButton4 = True Then
TextBox5.BackColor = &HFF8080
Else
TextBox4.BackColor = &H80000005
End If
'5
If TextBox6.Text = TextBox7.Text And OptionButton5 = True Then
TextBox6.BackColor = &HFF8080
Else
TextBox6.BackColor = &H80000005
End If

End Sub

Yukarıdaki kod ile istediğimi yapabiliyorum. Ancak bu kodu aynı userform üzerindeki diğer sorulara da uygulamam lazım. Kısa bir kodu olabilir mi acaba?
 
Döngü ile textbox taki değere göre yazılarımızın rengini kırmızıya çevirebilir miyiz

Merhabalar hocam bunu bir döngü ile yapamaz mıyız?
örnek 2 den 10 a kadar textboxlarımız var bunlardan

değeri "H" olanları

tek tek kırmızı kodu vermek yerine bunu döngü ile nasıl yapabiliriz ?


If TextBox2.Text = ""H"" Then

TextBox2.BackColor = RGB(255,0,0)

Else

TextBox2.BackColor = RGB(0,0,0)
End If







Kod:
Private Sub CommandButton19_Click()
'1If TextBox2.Text = TextBox7.Text And OptionButton1 = True Then
TextBox2.BackColor = &HFF8080
Else
TextBox2.BackColor = &H80000005
End If
'2
If TextBox3.Text = TextBox7.Text And OptionButton2 = True Then
TextBox3.BackColor = &HFF8080
Else
End If
TextBox3.BackColor = &H80000005
'3
If TextBox4.Text = TextBox7.Text And OptionButton3 = True Then
TextBox4.BackColor = &HFF8080
Else
TextBox4.BackColor = &H80000005
End If
'4
If TextBox5.Text = TextBox7.Text And OptionButton4 = True Then
TextBox5.BackColor = &HFF8080
Else
TextBox4.BackColor = &H80000005
End If
'5
If TextBox6.Text = TextBox7.Text And OptionButton5 = True Then
TextBox6.BackColor = &HFF8080
Else
TextBox6.BackColor = &H80000005
End If

End Sub

Yukarıdaki kod ile istediğimi yapabiliyorum. Ancak bu kodu aynı userform üzerindeki diğer sorulara da uygulamam lazım. Kısa bir kodu olabilir mi acaba?
 
Geri
Üst