• DİKKAT

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

MsgBox yazı değiştirme

muratgunay48

Altın Üye
Katılım
10 Şubat 2010
Mesajlar
1,514
Excel Vers. ve Dili
Office 365 - Türkçe (64 bit)
Arkadaşlar, sayın hocalarım, sadece görsellik, MsgBox yazısını değiştirmeyi araştırmıştım hatta forumda sormuştum. İnternette araştırdım buldum.
Paylaşmak istedim. Örnek dosya koydum. O MsgBox nasıl kullanılabilir henüz çalışma yapmadım. Hatta hocalarımız bir örnek yaparlarsa çok faydalı olur.
Teşekkür ederim.
Saygılarımla.
 

Ekli dosyalar

Sayın hocalarım A1 hücresini boya diye yazdım. Ama her hâlükârda boyuyor. Boya deyince tamam da.

Kod:
Sub Custom_MsgBox_Demo1()
    MsgBoxCustom_Set vbOK, "Boya"
    MsgBoxCustom_Set vbCancel, "Boyama"
    MsgBoxCustom ans, "A1'i yeşile boyayayım mı?", vbOKCancel, "muratgunay48"
    
    If answer = Boya Then
    
    Range("A1").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 5287936
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    
Else

    If answer = Boyama Then
 
  MsgBox "İyi madem beyaz dursun."
 
  End If
    
  End If
    
End Sub
 
Merhaba koşulunuzu,

"Boya" yerine vbOK, "Boyama" yerine vbCancel olarak düzeltip deneyiniz.
 
Böyle deneyiniz.

C++:
Sub Custom_MsgBox_Demo1()
    MsgBoxCustom_Set vbOK, "Boya"
    MsgBoxCustom_Set vbCancel, "Boyama"
    MsgBoxCustom ans, "A1'i yeşile boyayayım mı?", vbOKCancel, "muratgunay48"
    
    Select Case ans
        Case 1: Range("A1").Interior.Color = 5287936
        Case 2: Range("A1").Interior.Color = -4142
                MsgBox "İyi madem beyaz dursun."
    End Select
End Sub
 
Korhan Bey kodunuzu çalışır şekilde kısaltmış,
Kendi verdiğiniz kodu bu şekilde düzenlerseniz de çalışacaktır.
iyi çalışmalar.

Rich (BB code):
Sub Custom_MsgBox_Demo1()
    Dim answer As VbMsgBoxResult 
    
    MsgBoxCustom_Set vbOK, "Boya"
    MsgBoxCustom_Set vbCancel, "Boyama"
    
    MsgBoxCustom answer, "A1'i yeşile boyayayım mı?", vbOKCancel, "muratgunay48"
    
    If answer = vbOK Then
        With Range("A1").Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 5287936 ' Yeşil renk kodu
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
    Else
        MsgBox "İyi madem beyaz dursun."
    End If
End Sub
 
Böyle deneyiniz.

C++:
Sub Custom_MsgBox_Demo1()
    MsgBoxCustom_Set vbOK, "Boya"
    MsgBoxCustom_Set vbCancel, "Boyama"
    MsgBoxCustom ans, "A1'i yeşile boyayayım mı?", vbOKCancel, "muratgunay48"
   
    Select Case ans
        Case 1: Range("A1").Interior.Color = 5287936
        Case 2: Range("A1").Interior.Color = -4142
                MsgBox "İyi madem beyaz dursun."
    End Select
End Sub

Kod:
Sub Custom_MsgBox_Demo1()
    MsgBoxCustom_Set vbOK, "Boya"
    MsgBoxCustom_Set vbCancel, "Boyama"
    MsgBoxCustom ans, "A1'i yeşile boyayayım mı?", vbOKCancel, "muratgunay48"
    
    Select Case ans
        Case 1: call aaa
        Case 2: call bbb
                MsgBox "İyi madem beyaz dursun."
    End Select
End Sub

Çok ama çok teşekkür ederim. Sağ olun var olun.

Şeklinde de kullanılabilir değil mi hocam?
 
Böyle deneyiniz.

C++:
Sub Custom_MsgBox_Demo1()
    MsgBoxCustom_Set vbOK, "Boya"
    MsgBoxCustom_Set vbCancel, "Boyama"
    MsgBoxCustom ans, "A1'i yeşile boyayayım mı?", vbOKCancel, "muratgunay48"
   
    Select Case ans
        Case 1: Range("A1").Interior.Color = 5287936
        Case 2: Range("A1").Interior.Color = -4142
                MsgBox "İyi madem beyaz dursun."
    End Select
End Sub

Hocam modül1'de değişiklik mi yapmak gerekiyor. Sadece modül2'de değiştirdim.

Kod:
Sub Custom_MsgBox_Demo1()
    MsgBoxCustom_Set vbYes, "Boya"
    MsgBoxCustom_Set vbNo, "Boyama"
    MsgBoxCustom_Set vbCancel, "İptal"
    MsgBoxCustom ans, "A1'i yeşile boyayayım mı?", vbYesNoCancel, "muratgunay48"
    
    Select Case ans
        Case 1: Range("A1").Interior.Color = 5287936
                MsgBox "Boyadım.", vbInformation, "muratgunay48"
        Case 2: Range("A1").Interior.Color = -4142
                MsgBox "İyi madem beyaz dursun.", vbInformation, "muratgunay48"
        Case 3: Exit Sub
    End Select
End Sub

Bu şekilde çalışmadı. Neden acaba?
 
Hocam modül1'de değişiklik mi yapmak gerekiyor. Sadece modül2'de değiştirdim.

Kod:
Sub Custom_MsgBox_Demo1()
    MsgBoxCustom_Set vbYes, "Boya"
    MsgBoxCustom_Set vbNo, "Boyama"
    MsgBoxCustom_Set vbCancel, "İptal"
    MsgBoxCustom ans, "A1'i yeşile boyayayım mı?", vbYesNoCancel, "muratgunay48"
  
    Select Case ans
        Case 1: Range("A1").Interior.Color = 5287936
                MsgBox "Boyadım.", vbInformation, "muratgunay48"
        Case 2: Range("A1").Interior.Color = -4142
                MsgBox "İyi madem beyaz dursun.", vbInformation, "muratgunay48"
        Case 3: Exit Sub
    End Select
End Sub

Bu şekilde çalışmadı. Neden acaba?

Private Sub MsgBoxCustom_Init()
' Initialize default button labels for Public Sub MsgBoxCustom
Dim nID As Integer
Dim vA As Variant ' base 0 array populated by Array function (must be Variant)
vA = VBA.Array(vbNullString, "OK", "Cancel", "Abort", "Retry", "Ignore", "Yes", "No") 'Bu kısmı düzenledim olmadı
For nID = 1 To 7
sMsgBoxDefaultLabel(nID) = vA(nID)
sMsgBoxCustomLabel(nID) = sMsgBoxDefaultLabel(nID)
Next nID
bMsgBoxCustomInit = True
End Sub
 
Kodları aynı modül içine yerleştirip deneyiniz.
 
Kodları aynı modül içine yerleştirip deneyiniz.
Hocam şöyle bir not düşmüş kod yazan ama
' Hook flags (Computer Based Training)
Private Const WH_CBT = 5 ' hook type
Private Const HCBT_ACTIVATE = 5 ' activate window
' MsgBox constants (these are enumerated by VBA)
' vbOK = 1, vbCancel = 2, vbAbort = 3, vbRetry = 4, vbIgnore = 5, vbYes = 6, vbNo = 7 (these are button IDs)
' for 1 button, use vbOKOnly = 0 (OK button with ID vbOK returned)
' for 2 buttons, use vbOKCancel = 1 (vbOK, vbCancel) or vbYesNo = 4 (vbYes, vbNo) or vbRetryCancel = 5 (vbRetry, vbCancel)
' for 3 buttons, use vbAbortRetryIgnore = 2 (vbAbort, vbRetry, vbIgnore) or vbYesNoCancel = 3 (vbYes, vbNo, vbCancel)
' Module level global variables
Private sMsgBoxDefaultLabel(1 To 7) As String
Private sMsgBoxCustomLabel(1 To 7) As String
Private bMsgBoxCustomInit As Boolean

Değiştirecek yeri bulamıyorum.
 
Deneyiniz.

C++:
Sub Custom_MsgBox_Demo1()
    MsgBoxCustom_Set vbYes, "Boya"
    MsgBoxCustom_Set vbNo, "Boyama"
    MsgBoxCustom_Set vbCancel, "İptal"
    MsgBoxCustom ans, "A1'i yeşile boyayayım mı?", vbYesNoCancel, "muratgunay48"
    
    Select Case ans
        Case 6: Range("A1").Interior.Color = 5287936
                MsgBox "Boyadım.", vbInformation, "muratgunay48"
        Case 7: Range("A1").Interior.Color = -4142
                MsgBox "İyi madem beyaz dursun.", vbInformation, "muratgunay48"
        Case 2: Exit Sub
    End Select
End Sub
 
Deneyiniz.

C++:
Sub Custom_MsgBox_Demo1()
    MsgBoxCustom_Set vbYes, "Boya"
    MsgBoxCustom_Set vbNo, "Boyama"
    MsgBoxCustom_Set vbCancel, "İptal"
    MsgBoxCustom ans, "A1'i yeşile boyayayım mı?", vbYesNoCancel, "muratgunay48"
   
    Select Case ans
        Case 6: Range("A1").Interior.Color = 5287936
                MsgBox "Boyadım.", vbInformation, "muratgunay48"
        Case 7: Range("A1").Interior.Color = -4142
                MsgBox "İyi madem beyaz dursun.", vbInformation, "muratgunay48"
        Case 2: Exit Sub
    End Select
End Sub
Hocam her şeyi denedim de. Case ismi değiştirmek hiç aklıma gelmemişti. Çok teşekkür ederim. Sağ olun. Var olun.
 
Geri
Üst