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

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

قام بنشر (معدل)

اريد ان اختصر هذا الكود فى سطر او سطرين او كما يتراء  لخبراء المنتدى  

 


If Me.commanfaz = "منفذ1" Then
Me.txt1.Visible = True
Me.txtm1.Visible = True
Me.txtID.Enabled = False
Me.txtitems.Enabled = False
Me.txtmag.Enabled = False

Else
Me.txt1.Visible = False
Me.txtm1.Visible = False
Me.txt2.Visible = False
Me.txtm2.Visible = False
Me.txt3.Visible = False
Me.txtm3.Visible = False
Me.txt4.Visible = False
Me.txtm4.Visible = False
Me.txt5.Visible = False
Me.txtm5.Visible = False
Me.txt6.Visible = False
Me.txtm6.Visible = False
Me.txt7.Visible = False
Me.txtm7.Visible = False
Me.txt8.Visible = False
Me.txtm8.Visible = False
Me.txtmst.Visible = False
Me.txtstrorag.Visible = False

If Me.commanfaz = "منفذ2" Then
Me.txt2.Visible = True
Me.txtm2.Visible = True
Me.txtID.Enabled = False
Me.txtitems.Enabled = False
Me.txtmag.Enabled = False

Else
Me.txt1.Visible = False
Me.txtm1.Visible = False
Me.txt2.Visible = False
Me.txtm2.Visible = False
Me.txt3.Visible = False
Me.txtm3.Visible = False
Me.txt4.Visible = False
Me.txtm4.Visible = False
Me.txt5.Visible = False
Me.txtm5.Visible = False
Me.txt6.Visible = False
Me.txtm6.Visible = False
Me.txt7.Visible = False
Me.txtm7.Visible = False
Me.txt8.Visible = False
Me.txtm8.Visible = False
Me.txtmst.Visible = False
Me.txtstrorag.Visible = False

If Me.commanfaz = "منفذ3" Then
Me.txt3.Visible = True
Me.txtm3.Visible = True
Me.txtID.Enabled = False
Me.txtitems.Enabled = False
Me.txtmag.Enabled = False

Else
Me.txt1.Visible = False
Me.txtm1.Visible = False
Me.txt2.Visible = False
Me.txtm2.Visible = False
Me.txt3.Visible = False
Me.txtm3.Visible = False
Me.txt4.Visible = False
Me.txtm4.Visible = False
Me.txt5.Visible = False
Me.txtm5.Visible = False
Me.txt6.Visible = False
Me.txtm6.Visible = False
Me.txt7.Visible = False
Me.txtm7.Visible = False
Me.txt8.Visible = False
Me.txtm8.Visible = False
Me.txtmst.Visible = False
Me.txtstrorag.Visible = False


end if

end if

end if

 

تم تعديل بواسطه Moosak
تنسيق الكود
قام بنشر

سطر أو سطرين ، الله يسامحك 😅

اذا بالسطور تقدر تخليه سطر واحد وهو إنك تحط السطور جنب بعضها وتفصل بينهم بعلامة نقطتين : ، وإذا الفكرة بتغيير المنهج اللي انت متبعه ، فجرب هذا الكود

 

Select Case Me.commanfaz
    Case "منفذ1"
        ShowControls True
        Me.txtID.Enabled = False
        Me.txtitems.Enabled = False
        Me.txtmag.Enabled = False
    Case "منفذ2"
        ShowControls True
        Me.txt2.Visible = True
        Me.txtm2.Visible = True
        Me.txtID.Enabled = False
        Me.txtitems.Enabled = False
        Me.txtmag.Enabled = False
    Case "منفذ3"
        ShowControls True
        Me.txt3.Visible = True
        Me.txtm3.Visible = True
        Me.txtID.Enabled = False
        Me.txtitems.Enabled = False
        Me.txtmag.Enabled = False
    Case Else
        ShowControls False
End Select

Sub ShowControls(visibility As Boolean)
    Me.txt1.Visible = visibility
    Me.txtm1.Visible = visibility
    Me.txt2.Visible = visibility
    Me.txtm2.Visible = visibility
    Me.txt3.Visible = visibility
    Me.txtm3.Visible = visibility
    Me.txt4.Visible = visibility
    Me.txtm4.Visible = visibility
    Me.txt5.Visible = visibility
    Me.txtm5.Visible = visibility
    Me.txt6.Visible = visibility
    Me.txtm6.Visible = visibility
    Me.txt7.Visible = visibility
    Me.txtm7.Visible = visibility
    Me.txt8.Visible = visibility
    Me.txtm8.Visible = visibility
    Me.txtmst.Visible = visibility
    Me.txtstrorag.Visible = visibility
End Sub

 

  • Like 1
قام بنشر

وهذه محاولة لتقليص حجم الكود أيضا 🙂 

Dim x As Integer

For x = 1 To 8
    Me("txt" & x).Visible = False
    Me("txtm" & x).Visible = False
Next x

Me.txtmst.Visible = False
Me.txtstrorag.Visible = False
Me.txtID.Enabled = False
Me.txtitems.Enabled = False
Me.txtmag.Enabled = False

If Me.commanfaz = "منفذ1" Then
    Me.txt1.Visible = True
    Me.txtm1.Visible = True
ElseIf Me.commanfaz = "منفذ2" Then
    Me.txt2.Visible = True
    Me.txtm2.Visible = True
ElseIf Me.commanfaz = "منفذ3" Then
    Me.txt3.Visible = True
    Me.txtm3.Visible = True
End If

 

  • Like 1
  • Thanks 1
  • Moosak changed the title to اختصار الكود

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.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information