17-12-24, 12:39 PM (آخر تعديل لهذه المشاركة : 19-12-24, 10:21 AM {2} بواسطة hsab.)
السلام عليكم ورحمة الله
ارجو مساعدتى فى صياغة دالة لحساب حجم المنتج بالخزان وفقا للمعلومات المرفقة على ان تكون الدالة كما التالى
Public Function CalcVolume(TKNo As Integer, DipV As Double) As Double
Dim DipCM As Integer
Dim RemainingMM As Double
Dim BaseVolume As Double
END FUNCTION
والمعلومات مرفقة
17-12-24, 03:23 PM (آخر تعديل لهذه المشاركة : 17-12-24, 03:27 PM {2} بواسطة hsab.)
هذه ممكن تفيد لكن النتيجة خطأ ارجو تعديله
Public Function calcvolume1(TKNo As Integer, DipV As Integer) As Double
Dim Volume As Double
Dim DipV_cm As Double
' تحويل DipV من مليمتر إلى سنتيمتر
DipV_cm = DipV / 10#
' التعامل مع الخزان الأول
If TKNo = 1 Then
Select Case DipV
Case 0 ' 0 mm
Volume = 0
Case 1: Volume = 452
Case 2: Volume = 904
Case 3: Volume = 1355
Case 4: Volume = 1807
Case 5: Volume = 2259
Case 6: Volume = 2711
Case 7: Volume = 3163
Case 8: Volume = 3615
Case 9: Volume = 4066
Case Else
' قياس بالسنتيمتر
Select Case DipV_cm
Case 0: Volume = 35287
Case 1: Volume = 39801
Case 36: Volume = 197761
Case 37: Volume = 202276
Case 68: Volume = 342245
Case 69: Volume = 346761
Case 70: Volume = 486725
' القياسات الأكبر
Case 100: Volume = 486725
Case 190: Volume = 892917
Case 191: Volume = 897431
Case 192: Volume = 901945
Case 199: Volume = 933564
Case Else
' حساب الفرق للسنتيمتر
If DipV_cm < 36 Then
Volume = 35287 + (DipV_cm * 4513)
ElseIf DipV_cm < 68 Then
Volume = 197761 + ((DipV_cm - 36) * 4515)
ElseIf DipV_cm < 100 Then
Volume = 342245 + ((DipV_cm - 68) * 4515)
ElseIf DipV_cm < 190 Then
Volume = 486725 + ((DipV_cm - 100) * 4513)
End If
End Select
End Select
End If
' إرجاع كمية السائل
CalcVolume = Volume
End Function
وهذه إجابة الذكاء الصناعى
Public Function calcvolume(TKNo As Integer, DipV As Integer) As Double
Dim Volume As Double
Dim DipV_cm As Double
' تحويل DipV من مليمتر إلى سنتيمتر
DipV_cm = DipV / 10#
' التعامل مع الخزان الأول
If TKNo = 1 Then
' نفس الشيفرة الخاصة بالخزان 1
' التعامل مع الخزان الثاني
ElseIf TKNo = 2 Then
Select Case DipV
Case 0
Volume = 0
Case 1: Volume = 500
Case 2: Volume = 1000
' أضف المزيد من الحالات هنا
Case Else
' يمكنك حساب القيم هنا أيضًا
If DipV_cm < 50 Then
Volume = 5000 + (DipV_cm * 100) ' مجرد مثال على حساب الحجم
Else
' حساب الحجم الآخر
End If
End Select
End If
' إرجاع كمية السائل
calcvolume = Volume
End Function