Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim t As Double
j = 1000
t = 0
For i = 1 To 10
j = j + 1000
t = t + j * 12
Next i
Text1.Text = Str(j) + Str(t)
j = 1000
t = 0
For i = 1 To 20
t = t + j * 6
j = j + 300
Next i
Text1.Text = Text1.Text + " " + Str(j) + Str(t)End Sub
Dim i As Integer
Dim j As Integer
Dim t As Double
j = 1000
t = 0
For i = 1 To 10
j = j + 1000
t = t + j * 12
Next i
Text1.Text = Str(j) + Str(t)
j = 1000
t = 0
For i = 1 To 20
t = t + j * 6
j = j + 300
Next i
Text1.Text = Text1.Text + " " + Str(j) + Str(t)End Sub
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Dim t As Double
j = 1000
t = 0
For i = 1 To 10
j = j + 1000
t = t + j * 12#
Next i
Text1.Text = Str(j) + Str(t)
j = 1000
t = 0
For i = 1 To 20
t = t + j * 6#
j = j + 300
Next i
Text1.Text = Text1.Text + " " + Str(j) + Str(t)End Sub因为j是整型,j*12也是整型,j*12会溢出,将12转为浮点型就ok了