اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

مشكله قاعده if مع msgbox


king5star

الردود الموصى بها

السلام عليكم اخوانى

معي مشكلة مع قاعدة if و msgbox مكون من ثلاث ازرر

فاننى اريد عند الضغط على yes ينفذ امر و no يغلق النموذج و cancel يبقي كل شئ كما هو فقمت باستخدام هذا الكود ولكن تعمل yes فقط

style = vbYesNoCancel + vbMsgBoxRight + vbQuestion
Title = "تجربة"
           If MsgBox("تجربة1", style, Title) = vbYes Then
           MsgBox "تم بنجاح", vbInformation
            ElseIf vbCancel Then
            DoCmd.Requery
            ElseIf vbNo Then
            DoCmd.Quit
            Else
            'no thing
            End If

فما الخطأ

رابط هذا التعليق
شارك

السلام عليكم

لتحديد مسار مختلف لكل زر عليك ان تضيف متغير من نوع String وتكون قيمتة هي الرسالة وبعد ذلك تستخدم عبارة IF

وهذا مثال :

Dim Msg As String
Msg = MsgBox("aaaaa", vbYesNoCancel)
If Msg = vbYes Then
    MsgBox "yes"
ElseIf Msg = vbNo Then MsgBox "no"
Else
     MsgBox "cancel"
End If

 

 

  • Like 1
رابط هذا التعليق
شارك

12 ساعات مضت, osama ababneh said:

السلام عليكم

لتحديد مسار مختلف لكل زر عليك ان تضيف متغير من نوع String وتكون قيمتة هي الرسالة وبعد ذلك تستخدم عبارة IF

وهذا مثال :


Dim Msg As String
Msg = MsgBox("aaaaa", vbYesNoCancel)
If Msg = vbYes Then
    MsgBox "yes"
ElseIf Msg = vbNo Then MsgBox "no"
Else
     MsgBox "cancel"
End If

 

 

شكراً اخى على اهتمامك لقد جربت هذا سلفاً ولكن الرسالة تظهر دون شروط اننى استخدم هذا الكود داخل قاعدة if اخري ولكنها لم تعمل فتظر الرسالة سواء الشرط محقق او لا وهذا مثال للمقصود

Dim msg, style, Title, result As String

style = vbYesNoCancel + vbMsgBoxRight + vbQuestion
Title = "تجربة"
result = "تجربة1"
msg =  MsgBox(result, style, Title)        
        If Acti = 1 Then
           If msg = vbYes Then
           MsgBox "تم بنجاح", vbInformation
            ElseIf msg = vbCancel Then
            DoCmd.Requery
            ElseIf msg = vbNo Then
            DoCmd.Quit
            Else
            'no thing
            End If
            Else
        DoCmd.Quit
        End If

 

رابط هذا التعليق
شارك

11 دقائق مضت, king5star said:

شكراً اخى على اهتمامك لقد جربت هذا سلفاً ولكن الرسالة تظهر دون شروط اننى استخدم هذا الكود داخل قاعدة if اخري ولكنها لم تعمل فتظر الرسالة سواء الشرط محقق او لا وهذا مثال للمقصود


Dim msg, style, Title, result As String

style = vbYesNoCancel + vbMsgBoxRight + vbQuestion
Title = "تجربة"
result = "تجربة1"
msg =  MsgBox(result, style, Title)        
        If Acti = 1 Then
           If msg = vbYes Then
           MsgBox "تم بنجاح", vbInformation
            ElseIf msg = vbCancel Then
            DoCmd.Requery
            ElseIf msg = vbNo Then
            DoCmd.Quit
            Else
            'no thing
            End If
            Else
        DoCmd.Quit
        End If

 

جرب هذا
 

style = vbYesNoCancel + vbMsgBoxRight + vbQuestion
Title = "تجربة"
x = MsgBox("تجربة1", style, Title)
           If x = vbYes Then
                MsgBox "تم بنجاح", vbInformation
                    ElseIf x = vbNo Then
                        MsgBox "تم بنجاح نو", vbInformation
                    ElseIf x = vbCancel Then
                MsgBox "تم بنجاح كانسل", vbInformation
            End If

واليك ملف لتعم الفائدة
 

ifmsgbox.rar

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • اضف...

Important Information