看看这个程序,怎么老是溢出啊?
在list1中随机产生了12个加油站的名称,通过INPUTBOX在list2中输入了12个需求数量,然后对这12个数从头开始加,如果大于18则停止,然后从停止的那个数接着加,大于18停止,直到加完,在c(j)中输出.
Private Sub Command2_Click()
Dim i As Integer
Dim sumZL As Single
i = List1.ListIndex
For i = 0 To 11
For j = 0 To 9
c(j) = ""
sumZL = 0
Do While (i >= 11)
sumZL = sumZL + a(i)
If sumZL > 18 Then
Exit Do
i = i - 1
End If
If a(i) <> 0 Then
c(j) = c(j) & "→" & 加油站 & i + 1
End If
i = i + 1
Loop
Next j
Next i
Form1.Visible = False
Form2.Visible = True
End Sub
这段程序老出错,我又看不出毛病,帮帮忙了!!!