Описание функционирование формы (события) с приведением листинга соответствующих процедур
Private Sub SpinButton1_SpinUp()
TextBox1.Value = CStr(CDbl(TextBox1.Value) + 1)
End Sub
Private Sub SpinButton1_SpinDown()
TextBox1.Value = CStr(CDbl(TextBox1.Value) - 1)
End Sub
Private Sub SpinButton2_SpinUp()
TextBox2.Value = CStr(CDbl(TextBox2.Value) + 1)
End Sub
Private Sub SpinButton2_SpinDown()
TextBox2.Value = CStr(CDbl(TextBox2.Value) - 1)
End Sub
Private Sub SpinButton3_SpinUp()
TextBox3.Value = CStr(CDbl(TextBox3.Value) + 1)
End Sub
Private Sub SpinButton3_SpinDown()
TextBox3.Value = CStr(CDbl(TextBox3.Value) - 1)
End Sub
Private Sub SpinButton4_SpinUp()
TextBox4.Value = CStr(CDbl(TextBox4.Value) + 1)
End Sub
Private Sub SpinButton4_SpinDown()
TextBox4.Value = CStr(CDbl(TextBox4.Value) - 1)
End Sub
Private Sub SpinButton5_SpinUp()
TextBox5.Value = CStr(CDbl(TextBox5.Value) + 1)
End Sub
Private Sub SpinButton5_SpinDown()
TextBox5.Value = CStr(CDbl(TextBox5.Value) - 1)
End Sub
Private Sub SpinButton6_SpinUp()
TextBox6.Value = CStr(CDbl(TextBox6.Value) + 1)
End Sub
Private Sub SpinButton6_SpinDown()
TextBox6.Value = CStr(CDbl(TextBox6.Value) - 1)
End Sub
Private Sub SpinButton7_SpinUp()
TextBox7.Value = CStr(CDbl(TextBox7.Value) + 1)
End Sub
Private Sub SpinButton7_SpinDown()
TextBox7.Value = CStr(CDbl(TextBox7.Value) - 1)
End Sub
Private Sub SpinButton8_SpinUp()
TextBox8.Value = CStr(CDbl(TextBox8.Value) + 1)
End Sub
Private Sub SpinButton8_SpinDown()
TextBox8.Value = CStr(CDbl(TextBox8.Value) - 1)
End Sub
Private Sub UserForm_Initialize()
TextBox1.Value = Worksheets(1).Cells(11, 6)
TextBox2.Value = Worksheets(1).Cells(14, 6)
TextBox3.Value = Worksheets(1).Cells(22, 6)
TextBox4.Value = Worksheets(1).Cells(25, 6)
TextBox5.Value = Worksheets(1).Cells(28, 6)
TextBox6.Value = Worksheets(1).Cells(31, 6)
TextBox7.Value = Worksheets(1).Cells(35, 6)
TextBox8.Value = Worksheets(1).Cells(39, 6)
CommandButton3.Enabled = False
End Sub
Private Sub CommandButton1_Click()
Dim a As String
If Not IsNumeric(TextBox1.Text) Then
MsgBox "Введите число", vbExclamation
Exit Sub
End If
If Not IsNumeric(TextBox2.Text) Then
MsgBox "Введите число", vbExclamation
Exit Sub
End If
If Not IsNumeric(TextBox3.Text) Then
MsgBox "Введите число", vbExclamation
Exit Sub
End If
If Not IsNumeric(TextBox4.Text) Then
MsgBox "Введите число", vbExclamation
Exit Sub
End If
If Not IsNumeric(TextBox5.Text) Then
MsgBox "Введите число", vbExclamation
Exit Sub
End If
If Not IsNumeric(TextBox6.Text) Then
MsgBox "Введите число", vbExclamation
Exit Sub
End If
If Not IsNumeric(TextBox7.Text) Then
MsgBox "Введите число", vbExclamation
Exit Sub
End If
If Not IsNumeric(TextBox8.Text) Then
MsgBox "Введите число", vbExclamation
Exit Sub
End If
If TextBox1.Text < 0 Or TextBox2.Text < 0 Or TextBox3.Text < 0 Or TextBox4.Text < 0 Or TextBox5.Text < 0 Or TextBox6.Text < 0 Or TextBox7.Text < 0 Or TextBox8.Text < 0 Then
MsgBox "Проверьте значения!", vbCritical, "Ошибка"
Exit Sub
End If
a = MsgBox("Внести изменения?", vbYesNo + vbQuestion + vbDefaultButton1)
If a = 6 Then
Worksheets(1).Range("F11") = TextBox1.Text
Worksheets(1).Range("F14") = TextBox2.Text
Worksheets(1).Range("F22") = TextBox3.Text
Worksheets(1).Range("F25") = TextBox4.Text
Worksheets(1).Range("F28") = TextBox5.Text
Worksheets(1).Range("F31") = TextBox6.Text
Worksheets(1).Range("F35") = TextBox7.Text
Worksheets(1).Range("F39") = TextBox8.Text
End If
If a = 7 Then
Exit Sub
End If
End Sub
Private Sub CommandButton2_Click()
Dim SUM As Single
Dim SUM_RAS_MAT_I_MEX As Single
Dim TR_RAS As Single
Dim NAKL_RAS As Single
Dim SMET_PRIB As Single
Dim NDS As Single
Dim ITOGO As Single
a = Cells(11, 10)
b = Cells(14, 10)
c = Cells(22, 10)
d = Cells(25, 10)
l = Cells(28, 10)
f = Cells(31, 10)
g = Cells(35, 10)
k = Cells(39, 10)
SUM = a + b + c + d + l + f + g + k
q = Cells(11, 11)
w = Cells(14, 11)
e = Cells(22, 11)
r = Cells(25, 11)
t = Cells(28, 11)
y = Cells(31, 11)
u = Cells(35, 11)
i = Cells(39, 11)
SUM_RAS_MAT_I_MEX = q + w + e + r + t + y + u + i
TR_RAS = 0.15 * SUM
NAKL_RAS = 0.5 * (SUM - SUM_RAS_MAT_I_MEX)
SMET_PRIB = 0.3 * (SUM - SUM_RAS_MAT_I_MEX)
ITOGO = SUM + TR_RAS + NAKL_RAS + SMET_PRIB
NDS = 18 / 118 * ITOGO
TextBox9.Text = SUM
TextBox10.Text = SUM_RAS_MAT_I_MEX
TextBox11.Text = TR_RAS
TextBox12.Text = NAKL_RAS
TextBox13.Text = SMET_PRIB
TextBox15.Text = NDS
TextBox14.Text = ITOGO
Worksheets(1).Range("J43") = SUM
Worksheets(1).Range("J44") = SUM_RAS_MAT_I_MEX
Worksheets(1).Range("J45") = TR_RAS
Worksheets(1).Range("J46") = NAKL_RAS
Worksheets(1).Range("J47") = SMET_PRIB
Worksheets(1).Range("J48") = ITOGO
Worksheets(1).Range("J49") = NDS
CommandButton3.Enabled = True
End Sub
Private Sub CommandButton3_Click()
If TextBox5.Text = Empty Or TextBox6.Text = Empty Or TextBox7.Text = Empty Or TextBox8.Text = Empty Or TextBox9.Text = Empty Or TextBox10.Text = Empty Or TextBox11.Text = Empty Then
MsgBox "Подсчитайте итоги", vbCritical, "Ошибка"
Else
UserForm2.Show
End If
End Sub
Private Sub CommandButton4_Click()
Unload UserForm1
End Sub
3.3.3.Результаты работы формы (заполненная форма)
3.4.Общий вид формы “Параметры диаграммы”