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

解决方案 »

  1.   

    错,j溢出,将j改成 long 型
      

  2.   

    改成这样就可以了
    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了