(09-03-20, 08:35 PM)paveldida كتب : [ -> ]Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
TextBox7.Text = Val(TextBox7.Text) + 3000
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
TextBox8.Text = 2000
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
TextBox9.Text = 1800
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
TextBox10.Text = 1500
End Sub
كود الحساب كاآتي:
Dim a, b, c, d, f, g, h, j, k, l, m, n, y, t, i As Double
a = Val(TextBox1.Text)
f = Val(TextBox5.Text)
j = Val(TextBox7.Text)
k = Val(TextBox8.Text)
l = Val(TextBox9.Text)
m = Val(TextBox10.Text)
h = Val(TextBox7.Text)
b = a / 5
c = a * 5 / 100
If c <= 1500 Then
c = 1500
End If
d = a * 1 / 100
If d <= 2000 Then
d = 2000
End If
g = c / 2
If a > 1000000 Then
i = 15000 + 10000 + ((a - 1000000) * 0.01)
ElseIf a > 500000 Then
i = 15000 + ((a - 500000) * 0.02)
ElseIf a <= 500000 Then
i = 15000
End If
n = (i + h + k + l + m) * 19 / 100
t = c + d + f + i + h + k + l + m + n
y = t - g
TextBox2.Text = Str(b)
TextBox3.Text = Str©
TextBox4.Text = Str(d)
TextBox6.Text = Str(i)
TextBox13.Text = Str(g)
TextBox11.Text = Str(n)
TextBox12.Text = Str(t)
TextBox14.Text = Str(y)
TextBox1.Text = FormatNumber(a, 2)
TextBox2.Text = FormatNumber(b, 2)
TextBox3.Text = FormatNumber(c, 2)
TextBox4.Text = FormatNumber(d, 2)
TextBox5.Text = FormatNumber(f, 2)
TextBox6.Text = FormatNumber(i, 2)
TextBox7.Text = FormatNumber(h, 2)
TextBox8.Text = FormatNumber(k, 2)
TextBox9.Text = FormatNumber(l, 2)
TextBox10.Text = FormatNumber(m, 2)
TextBox11.Text = FormatNumber(n, 2)
TextBox12.Text = FormatNumber(t, 2)
TextBox13.Text = FormatNumber(g, 2)
TextBox14.Text = FormatNumber(y, 2)
End Sub
(09-03-20, 06:25 PM)alsalamoni كتب : [ -> ] (09-03-20, 04:46 PM)paveldida كتب : [ -> ]السلام عليكم
اصادف مشكل غريب عند اعادة الضغط على Botton الحساب للمرة الثانية تتغير القيم بالشكل التالي ، لاكن المشكل اواجهه في اجهزة دون الأخرى لاني جربت على اكثر من جهاز
ضع الكود الذي تستخدمه مع توضيح اي الصورتين صحيحة او كيف المفروض ان يكون الناتج صحيحا
الصورة على اليمين هي النتيجة الصحيحة
اي TextBox تريد تحويل محتواه الى رقم باستخدام Val يجب حذف الفاصله الخاصه بتنسيق الالوف مثل
كود :
Val(TextBox7.Text.Replace(",", ""))
فيصبح الكود
كود :
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
TextBox7.Text = Val(TextBox7.Text.Replace(",", "")) + 3000
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
TextBox8.Text = 2000
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
TextBox9.Text = 1800
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
TextBox10.Text = 1500
End Sub
كود الحساب كاآتي:
Dim a, b, c, d, f, g, h, j, k, l, m, n, y, t, i As Double
a = Val(TextBox1.Text.Replace(",", ""))
f = Val(TextBox5.Text.Replace(",", ""))
j = Val(TextBox7.Text.Replace(",", ""))
k = Val(TextBox8.Text.Replace(",", ""))
l = Val(TextBox9.Text.Replace(",", ""))
m = Val(TextBox10.Text.Replace(",", ""))
h = Val(TextBox7.Text.Replace(",", ""))
b = a / 5
c = a * 5 / 100
If c <= 1500 Then
c = 1500
End If
d = a * 1 / 100
If d <= 2000 Then
d = 2000
End If
g = c / 2
If a > 1000000 Then
i = 15000 + 10000 + ((a - 1000000) * 0.01)
ElseIf a > 500000 Then
i = 15000 + ((a - 500000) * 0.02)
ElseIf a <= 500000 Then
i = 15000
End If
n = (i + h + k + l + m) * 19 / 100
t = c + d + f + i + h + k + l + m + n
y = t - g
TextBox2.Text = Str(b)
TextBox3.Text = Str(c)
TextBox4.Text = Str(d)
TextBox6.Text = Str(i)
TextBox13.Text = Str(g)
TextBox11.Text = Str(n)
TextBox12.Text = Str(t)
TextBox14.Text = Str(y)
TextBox1.Text = FormatNumber(a, 2)
TextBox2.Text = FormatNumber(b, 2)
TextBox3.Text = FormatNumber(c, 2)
TextBox4.Text = FormatNumber(d, 2)
TextBox5.Text = FormatNumber(f, 2)
TextBox6.Text = FormatNumber(i, 2)
TextBox7.Text = FormatNumber(h, 2)
TextBox8.Text = FormatNumber(k, 2)
TextBox9.Text = FormatNumber(l, 2)
TextBox10.Text = FormatNumber(m, 2)
TextBox11.Text = FormatNumber(n, 2)
TextBox12.Text = FormatNumber(t, 2)
TextBox13.Text = FormatNumber(g, 2)
TextBox14.Text = FormatNumber(y, 2)
End Sub
لكن يجب ان تأخذ بعين الاعتبار الفاصلة المعتمدة في الاعدادت الاقليمية لنظام التشغيل الخاص بالجهاز الذي سيتم تشغيل التطبيق عليه
راجع موضوعك
مساعدة في كود تفقيط عربي
حسب الصورة التي على اليمين يبدو ان الفاصلة المعتمدة لتنسيق الالوف في هذا الجهاز هي المسافة
فيجب ان يتم حذفها بالطريقة التالية وتطبيق الطريقة نفسها على بقية TextBox التي في الكود
كود :
Val(TextBox7.Text.Replace(" ", ""))