Доброго времени суток. Я пишу курсовую (программу в VB). Логику знаю, но вот с воплощением программы в жизнь - проблемы. Во время выполнения циклов (при вводе определенных числ, которые "не нравятся" компилятору) выдается "Ошибка времени выполнения: Переполнение" (да, да, русская версия). Как избежать этого?
Даже если не читли мой код, что такое переполнение и с чем его едят? Может быть ссылку кините?
Вот кусок кода:
sngTaxRate = 0
vntBD0 = 0
While sngTaxRate <= 100
vntBD1 = sngTaxRate * vntProfit1
vntBD2 = sngTaxRate * vntProfit2
vntBD3 = sngTaxRate * vntProfit3
vntBD4 = sngTaxRate * vntProfit4
vntBD5 = sngTaxRate * vntProfit5
vntBD6 = sngTaxRate * vntProfit6
vntBD7 = sngTaxRate * vntProfit7
vntBD8 = sngTaxRate * vntProfit8
vntBD9 = sngTaxRate * vntProfit9
vntBD10 = sngTaxRate * vntProfit10
For i = 1 To bytYears
vntProfit1 = vntProfit1 * (1 - sngTaxRate / 100) * sngRent1
vntBD1 = vntBD1 + vntProfit1 * (sngTaxRate / 100)
vntProfit2 = vntProfit2 * (1 - sngTaxRate / 100) * sngRent2
vntBD2 = vntBD2 + vntProfit2 * (sngTaxRate / 100)
vntProfit3 = vntProfit3 * (1 - sngTaxRate / 100) * sngRent3
vntBD3 = vntBD3 + vntProfit3 * (sngTaxRate / 100)
vntProfit4 = vntProfit4 * (1 - sngTaxRate / 100) * sngRent4
vntBD4 = vntBD4 + vntProfit4 * (sngTaxRate / 100)
vntProfit5 = vntProfit5 * (1 - sngTaxRate / 100) * sngRent5
vntBD5 = vntBD5 + vntProfit5 * (sngTaxRate / 100)
vntProfit6 = vntProfit6 * (1 - sngTaxRate / 100) * sngRent6
vntBD6 = vntBD6 + vntProfit6 * (sngTaxRate / 100)
vntProfit7 = vntProfit7 * (1 - sngTaxRate / 100) * sngRent7
vntBD7 = vntBD7 + vntProfit7 * (sngTaxRate / 100)
vntProfit8 = vntProfit8 * (1 - sngTaxRate / 100) * sngRent8
vntBD8 = vntBD8 + vntProfit8 * (sngTaxRate / 100)
vntProfit9 = vntProfit9 * (1 - sngTaxRate / 100) * sngRent9
vntBD9 = vntBD9 + vntProfit9 * (sngTaxRate / 100)
vntProfit10 = vntProfit10 * (1 - sngTaxRate / 100) * sngRent10
vntBD10 = vntBD10 + vntProfit10 * (sngTaxRate / 100)
Next i
vntBD = vntBD1 + vntBD2 + vntBD3 + vntBD4 + vntBD5 + vntBD6 + vntBD7 + vntBD8 + vntBD9 + vntBD10
If vntBD > vntBD0 Then
vntBD0 = vntBD
sngTaxRate0 = sngTaxRate
End If
sngTaxRate = sngTaxRate + 0.1
Wend
типы данных:
Dim intFirstYear As Integer, intLastYear As Integer, sngTaxRate As Single, vntBD As Variant, _
vntBD1 As Variant, vntBD2 As Variant, vntBD3 As Variant, vntBD4 As Variant, vntBD5 As Variant, _
vntBD6 As Variant, vntBD7 As Variant, vntBD8 As Variant, vntBD9 As Variant, vntBD10 As Variant, _
vntProfit1 As Variant, sngRent1 As Single, _
vntProfit2 As Variant, sngRent2 As Single, _
vntProfit3 As Variant, sngRent3 As Single, _
vntProfit4 As Variant, sngRent4 As Single, _
vntProfit5 As Variant, sngRent5 As Single, _
vntProfit6 As Variant, sngRent6 As Single, _
vntProfit7 As Variant, sngRent7 As Single, _
vntProfit8 As Variant, sngRent8 As Single, _
vntProfit9 As Variant, sngRent9 As Single, _
vntProfit10 As Variant, sngRent10 As Single, _
vntBD0 As Variant, sngTaxRate0 As Single
Dim bytYears As Byte
Ответить
|