الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكلة في ElseIf

بدأه يسر في 13 يناير 2012 · 5 رد · 690 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم و رحمة الله و بركاتة

لدي مشكلة و هي ان الكمبيلر بنفذ اول جملة فقط من الif statement

If Application.OpenForms.Item("GoToForm").Created Then
                My.Application.OpenForms.Item("GoToForm").Activate()
                result = True
                MsgBox("1")

            ElseIf Application.OpenForms.Item("FindReplace").Created Then
                My.Application.OpenForms.Item("FindReplace").Activate()
                result = True
                MsgBox("2")

            ElseIf Application.OpenForms.Item("find_form").Created Then
                My.Application.OpenForms.Item("find_form").Activate()
                result = True
                MsgBox("3")
            Else
                result = False
                MsgBox("last")
            End If

اي جملة

If Application.OpenForms.Item("GoToForm").Created Then

فقط اما بقية الشروط فلا يتم تنفيذها او المرور عليها اصلا و لا اعرف ما السبب

سبحان الله و بحمده سبحان الله العظيم

#2

مع ان صار لي تقريبا 4 سنين بالبرمجه ولا مره تعاملت مع elseif : )

على فكره تقدر تكتب الكود بطريقه ثانيه ونفس النتيجه

For Each x As String In New String() {"GoToForm", "FindReplace", "find_form"}

Dim f As Form = My.Application.OpenForms(x)

If f IsNot Nothing Then

If f.Created Then

f.Activate()

result = True

MsgBox(x & ": Activated")

Else

MsgBox(x & ": not created")

End If

Else

MsgBox(x & ": is nothing")

End If

Next

1
#3

طريقتك حلوه بس القوتو حلقه تكرار يعني تكرر نفسها وترجع وتعيد لنفس الكلمه مارح تنزل للشروط الثانيه غير القوتو ويمكن تضبط معــك وردلي خبر هنا

#4

ما هو الغرض من هذا الكود ؟ وفيما يستخدم ؟

certifiedj.jpg

 

 

Image Hosted by ImageShack.us
#5

السلام عليكم ورحمه الله وبركاته

اختي اذا كان الفورم GoToForm مفتوح سوف يطبق الكود جميع جمل الشرط الاول, ولكن المشكلة لو كان الفوم مغلق ستحدث مشكلة انه لا يوجد اي مرجع للفورم

1

.:: Wish to become better and better ::.

#6

السلام عليكم

شكرا على تفاعلكم معي

فكرة الاخ ng كانت جيدة اشتغلت معي و كلام الاخ vb helper صحيح

الكود كان سيكون هكذا

'if goto form is opened send true 
            If Not Application.OpenForms.Item("GoToForm") Is Nothing Then

                If Application.OpenForms.Item("GoToForm").Created Then
                    My.Application.OpenForms.Item("GoToForm").Activate()
                    result = True
                End If
                'if FindReplace form is opened send true
            ElseIf Not Application.OpenForms.Item("FindReplace") Is Nothing Then
                If Application.OpenForms.Item("FindReplace").Created Then
                    My.Application.OpenForms.Item("FindReplace").Activate()
                    result = True
                End If
                'if find_form form is opened send true
            ElseIf Not Application.OpenForms.Item("find_form") Is Nothing Then
                If Application.OpenForms.Item("find_form").Created Then
                    My.Application.OpenForms.Item("find_form").Activate()
                    result = True
                End If

            Else 'send false if there isn't any opened forms
                result = False
            End If

اصبح الان هكذا

 For Each x As String In New String() {"GoToForm", "FindReplace", "find_form"}
            Dim f As Form = My.Application.OpenForms(x)
            If f IsNot Nothing Then
                If f.Created Then
                    f.Activate()
                    result = True

                End If

            End If
        Next

شكرا للجميع و جمعة مباركة

تم تعديل هذه المشاركة بواسطة يسر في 13 يناير 2012 في 19:53

سبحان الله و بحمده سبحان الله العظيم

مواضيع مشابهة