vb程序 出错在线等
PrivateSubCommand1_Click()Dimi,j,k,a,b,cDimxlApp,xlBook,xlSheet,HAsLong,LAsLongSetxlA...
Private Sub Command1_Click()
Dim i, j, k, a, b, c
Dim xlApp, xlBook, xlSheet, H As Long, L As Long
Set xlApp = CreateObject("Excel.Application") '启动 Excel
xlApp.Visible = True '显示 Excel 主程序窗口。
'打开一个工作簿
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1) '设置对第一个工作表的引用
L = 2 '结果放置到表格 2 列
For c = 1 To 33
For b = c + 1 To 33
For i = b + 1 To 33
For j = i + 1 To 33
For k = j + 1 To 33
For a = k + 1 To 33
If c + b + i + j + k = 88 Then
H = H + 1
xlSheet.Cells(H, L).Value = c & " " & b & " " & i & " " & j & " " & k & " " & a
End If
Next
Next
Next
Next
Next
Next
Set xlSheet = Nothing: Set xlBook = Nothing: Set xlApp = Nothing
End Sub
运行就提示xlSheet.Cells(H, L).Value = c & " " & b & " " & i & " " & j & " " & k & " " & a 这句话出错是怎么回事? 展开
Dim i, j, k, a, b, c
Dim xlApp, xlBook, xlSheet, H As Long, L As Long
Set xlApp = CreateObject("Excel.Application") '启动 Excel
xlApp.Visible = True '显示 Excel 主程序窗口。
'打开一个工作簿
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1) '设置对第一个工作表的引用
L = 2 '结果放置到表格 2 列
For c = 1 To 33
For b = c + 1 To 33
For i = b + 1 To 33
For j = i + 1 To 33
For k = j + 1 To 33
For a = k + 1 To 33
If c + b + i + j + k = 88 Then
H = H + 1
xlSheet.Cells(H, L).Value = c & " " & b & " " & i & " " & j & " " & k & " " & a
End If
Next
Next
Next
Next
Next
Next
Set xlSheet = Nothing: Set xlBook = Nothing: Set xlApp = Nothing
End Sub
运行就提示xlSheet.Cells(H, L).Value = c & " " & b & " " & i & " " & j & " " & k & " " & a 这句话出错是怎么回事? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询