HCBBS Forum (العربية)
Submit Chemical Projects / Find Solutions
Amplify Your Requirements on a Broader Chemical Platform *Engineering · Technology · Equipment · Solutions*
Submit Request

مثال على سكريبت Wincc 3: ترتيب السجلات في عنصر التحكم MSHFGrid حسب الحقول

2016-04-16View Original

Thread Content

أحيانًا نحتاج أيضًا إلى السماح للمستخدم بترتيب البيانات حسب الحقول بعد النقر على عنصر التحكم MSHFGrid، ويشرح هذا المقال كيفية تحقيق هذه الميزة. أولاً: الأعمال التحضيرية: في برنامج Wincc، يتم إنشاء متغير داخلي من نوع الأرقام العشرية ذات 32 بت باسم Sort، وذلك لتحديد ما إذا كان الترتيب تصاعديًا أم تنازليًا. أدخل نصًا ثابتًا في صفحة Wincc، وغيّر اسمه إلى “txt”. في خصائص النص، حدد خيار “التأثيرات” وضع قيمة “لا” للون العام. أما في خصائص اللون، فضع قيمة “الشفافية” على 100، وسمك الحدود على 0.

أما بالنسبة لسكريبت الترتيب، فقم بكتابة الكود التالي في حدث “MouseUp” لعنصر MSHFGrid:
```vba
Dim MSHFGrid, txt, sort
Set MSHFGrid = ScreenItems("MSHFGrid")
Set sort = HMIRuntime.Tags("Sort")
Set txt = ScreenItems("txt")

If MSHFGrid.TextMatrix(0, item.MouseCol) = “تاريخ/وقت” Then
If sort.Read = 2 Then
MSHFGrid.Sort = 1 ‘ترتيب تصاعدي حسب القيم العددية
sort.Write 1
txt.Text = “يتم الترتيب حاليًا حسب حقل “ & MSHFGrid.TextMatrix(0, item.MouseCol) & “ بشكل تصاعدي.”
Else
MSHFGrid.Sort = 2 ‘ترتيب تنازلي حسب القيم العددية
sort.Write 2
txt.Text = “يتم الترتيب حاليًا حسب حقل “ & MSHFGrid.TextMatrix(0, item.MouseCol) & “ بشكل تنازلي.”
End If
Else If sort.Read = 2 Then
MSHFGrid.Sort = 5 ‘ترتيب تصاعدي حسب الأحرف
sort.Write 1
txt.Text = “يتم الترتيب حاليًا حسب حقل “ & MSHFGrid.TextMatrix(0, item.MouseCol) & “ بشكل تصاعدي.”
Else
MSHFGrid.Sort = 6 ‘ترتيب تنازلي حسب الأحرف
sort.Write 2
txt.Text = “يتم الترتيب حاليًا حسب حقل “ & MSHFGrid.TextMatrix(0, item.MouseCol) & “ بشكل تنازلي.”
End If
End Sub
```

بعد حفظ الكود وتشغيله، سترى النتيجة. هذا السكريبت مبني على مشروع البروفيسور السابق؛ لمعرفة كيفية ربط عنصر MSHFGrid بجدول البيانات، يرجى الرجوع إلى المقالات الموصى بها حول سكريبتات WinCC الأخرى.
Reply #22016-04-17
هل يمكن تحميل ملف مضغوط؟

Submit a Project

**Looking for Chemical Technology, Equipment & Solutions?** No Registration Required Broader Platform Exposure | Global Chemical Service Provider Connections

Submit Request — Free Consultation

Disclaimer

This is an automated machine translation of the original thread. Some technical terms may have inaccuracies; the original text shall prevail. Click "View Original" at the top right to access the source page, which supports IP-based automatic real-time language translation. Please watch out for contact details and sales inducements to prevent fraud. All content and translations are for reference only, representing solely the poster's personal views. For enquiries, email service@hcbbs.com.