VB题目求解

2024-12-28 13:16:27
推荐回答(2个)
回答1:

完整代码如下:

Dim S1, S2, L As Double

Dim i As Integer

 

L = 1 + 0.08

S1 = 0

For i = 1 To 24

   S1 = S1 + 1000 * L ^ (i - 1)

Next i

 

S2 = 0

For i = 1 To 24

   S2 = S2 + 1000 + (i - 1) * 100

Next i

 

If S1 > S2 Then

   MsgBox "选择A公司"

Else

   MsgBox "选择B公司"

End If

运行结果显示选择:A

回答2:

Private Sub Form_Click()
Print "加工资的方式A:"
salary = 1000
For i = 1 To 24
salary = Round(salary * 1.08)
Print "第" & i & "个月:" & salary
suma = suma + salary
Next
Print "加工资的方式A24个月工资总和:" & suma

Print ""

Print "加工资的方式B:"
salary = 1000
For i = 1 To 24
salary = salary + 100
Print "第" & i & "个月:" & salary
sumb = sumb + salary
Next
Print "加工资的方式B24个月工资总和:" & sumb

Print ""

Print "加工资的方式A与加工资的方式B的差额:" & suma - sumb
End Sub