我想减少该程序的行数,请帮助 [英] I want to decrease lines of this program please help
问题描述
Private Sub btn_tarqeya_Click(sender As System.Object, e As System.EventArgs) Handles btn_years_inc.Click
Dim cur_degree As Integer = Val(txt_cur_degree.Text)
Dim cur_years As Integer = Val(txt_cur_years.Text)
Dim new_degree As Integer = Val(txt_new_degree.Text)
Dim new_years As Integer = Val(txt_new_years.Text)
Select Case cur_degree
Case 1
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt1s.Text) + Val(txt1inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt1s.Text) + Val(txt1inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt1s.Text) + Val(txt1inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt1s.Text) + Val(txt1inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt1s.Text) + Val(txt1inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt1s.Text) + Val(txt1inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt1s.Text) + Val(txt1inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt1s.Text) + Val(txt1inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt1s.Text) + Val(txt1inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 2
txt_new_salary.Text = Val(txt2s.Text)
End Select
Case 2
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt2s.Text) + Val(txt2inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt2s.Text) + Val(txt2inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt2s.Text) + Val(txt2inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt2s.Text) + Val(txt2inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt2s.Text) + Val(txt2inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt2s.Text) + Val(txt2inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt2s.Text) + Val(txt2inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt2s.Text) + Val(txt2inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt2s.Text) + Val(txt2inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 3
txt_new_salary.Text = Val(txt3s.Text)
End Select
Case 3
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt3s.Text) + Val(txt3inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt3s.Text) + Val(txt3inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt3s.Text) + Val(txt3inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt3s.Text) + Val(txt3inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt3s.Text) + Val(txt3inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt3s.Text) + Val(txt3inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt3s.Text) + Val(txt3inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt3s.Text) + Val(txt3inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt3s.Text) + Val(txt3inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 4
txt_new_salary.Text = Val(txt4s.Text)
End Select
Case 4
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt4s.Text) + Val(txt4inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt4s.Text) + Val(txt4inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt4s.Text) + Val(txt4inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt4s.Text) + Val(txt4inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt4s.Text) + Val(txt4inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt4s.Text) + Val(txt4inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt4s.Text) + Val(txt4inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt4s.Text) + Val(txt4inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt4s.Text) + Val(txt4inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 5
txt_new_salary.Text = Val(txt5s.Text)
End Select
Case 5
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt5s.Text) + Val(txt5inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt5s.Text) + Val(txt5inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt5s.Text) + Val(txt5inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt5s.Text) + Val(txt5inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt5s.Text) + Val(txt5inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt5s.Text) + Val(txt5inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt5s.Text) + Val(txt5inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt5s.Text) + Val(txt5inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt5s.Text) + Val(txt5inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 6
txt_new_salary.Text = Val(txt5s.Text)
Case 6
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt6s.Text) + Val(txt6inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt6s.Text) + Val(txt6inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt6s.Text) + Val(txt6inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt6s.Text) + Val(txt6inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt6s.Text) + Val(txt6inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt6s.Text) + Val(txt6inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt6s.Text) + Val(txt6inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt6s.Text) + Val(txt6inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt6s.Text) + Val(txt6inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 7
txt_new_salary.Text = Val(txt7s.Text)
End Select
Case 7
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt7s.Text) + Val(txt7inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt7s.Text) + Val(txt7inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt7s.Text) + Val(txt7inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt7s.Text) + Val(txt7inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt7s.Text) + Val(txt7inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt7s.Text) + Val(txt7inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt7s.Text) + Val(txt7inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt7s.Text) + Val(txt7inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt7s.Text) + Val(txt7inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 8
txt_new_salary.Text = Val(txt8s.Text)
End Select
Case 8
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt8s.Text) + Val(txt8inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt8s.Text) + Val(txt8inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt8s.Text) + Val(txt8inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt8s.Text) + Val(txt8inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt8s.Text) + Val(txt8inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt8s.Text) + Val(txt8inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt8s.Text) + Val(txt8inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt8s.Text) + Val(txt8inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt8s.Text) + Val(txt8inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 9
txt_new_salary.Text = Val(txt9s.Text)
End Select
Case 9
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt9s.Text) + Val(txt9inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt9s.Text) + Val(txt9inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt9s.Text) + Val(txt9inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt9s.Text) + Val(txt9inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt9s.Text) + Val(txt9inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt9s.Text) + Val(txt9inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt9s.Text) + Val(txt9inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt9s.Text) + Val(txt9inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt9s.Text) + Val(txt9inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 10
txt_new_salary.Text = Val(txt10s.Text)
End Select
Case 10
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt10s.Text) + Val(txt10inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt10s.Text) + Val(txt10inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt10s.Text) + Val(txt10inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt10s.Text) + Val(txt10inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt10s.Text) + Val(txt10inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt10s.Text) + Val(txt10inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt10s.Text) + Val(txt10inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt10s.Text) + Val(txt10inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt10s.Text) + Val(txt10inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 11
txt_new_salary.Text = Val(txt11s.Text)
End Select
Case 11
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt11s.Text) + Val(txt11inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt11s.Text) + Val(txt11inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt11s.Text) + Val(txt11inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt11s.Text) + Val(txt11inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt11s.Text) + Val(txt11inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt11s.Text) + Val(txt11inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt11s.Text) + Val(txt11inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt11s.Text) + Val(txt11inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt11s.Text) + Val(txt11inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 12
txt_new_salary.Text = Val(txt12s.Text)
End Select
End Select
Case 12
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt12s.Text) + Val(txt12inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt12s.Text) + Val(txt12inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt12s.Text) + Val(txt12inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt12s.Text) + Val(txt12inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt12s.Text) + Val(txt12inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt12s.Text) + Val(txt12inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt12s.Text) + Val(txt12inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt12s.Text) + Val(txt12inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt12s.Text) + Val(txt12inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 13
txt_new_salary.Text = Val(txt13s.Text)
End Select
Case 13
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt13s.Text) + Val(txt13inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt13s.Text) + Val(txt13inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt13s.Text) + Val(txt13inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt13s.Text) + Val(txt13inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt13s.Text) + Val(txt13inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt13s.Text) + Val(txt13inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt13s.Text) + Val(txt13inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt13s.Text) + Val(txt13inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt13s.Text) + Val(txt13inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 14
txt_new_salary.Text = Val(txt14s.Text)
End Select
Case 14
Select Case cur_years
Case 1
txt_new_years.Text = 2
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text)
Case 2
txt_new_years.Text = 3
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text) * 2
Case 3
txt_new_years.Text = 4
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text) * 3
Case 4
txt_new_years.Text = 5
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text) * 4
Case 5
txt_new_years.Text = 6
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text) * 5
Case 6
txt_new_years.Text = 7
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text) * 6
Case 7
txt_new_years.Text = 8
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text) * 7
Case 8
txt_new_years.Text = 9
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text) * 8
Case 9
txt_new_years.Text = 10
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text) * 9
Case 10
txt_new_years.Text = 0
txt_new_degree.Text = 14
txt_new_salary.Text = Val(txt14s.Text) + Val(txt14inc.Text) * 9
End Select
End Select
End Sub
End Class
我尝试过的事情:
thank you for help excuse me my english is weak.please help me
i will exolaine mean of textboxes.txtbox1s is first salary before increment .after every year we increase salary by txt1inc value .every year has a value of increment.after ten years we make a new "grade" for employ txt_degree is for grade,cur degree is current grade.thank you
What I have tried:
thank you for help excuse me my english is weak.please help me
i will exolaine mean of textboxes.txtbox1s is first salary before increment .after every year we increase salary by txt1inc value .every year has a value of increment.after ten years we make a new "grade" for employ txt_degree is for grade,cur degree is current grade.thank you
推荐答案
You should use arrays of controls (e.g.txts(5)
instead oftxt5s
) and arithmetic relations, in order to reduce all theCase
stuff to
You should use arrays of controls (e.g.txts(5)
instead oftxt5s
) and arithmetic relations, in order to reduce all theCase
stuff to
If cur_years < 10 Then
txt_new_years.Text = cur_years + 1
txt_new_salary.Text = Val(txts(cur_degree).Text) + Val(txtinc(cur_degree).Text) * cur_years
ElseIf cur_years = 10 Then
txt_new_years.Text = 0
txt_new_degree.Text = cur_degree + 1
txt_new_salary.Text = Val(txts(cur_degree + 1).Text)
Else
' handle error here
End
这篇关于我想减少该程序的行数,请帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!