vb 程序输出问题 在线等

来源:百度知道 编辑:UC知道 时间:2024/06/19 12:34:12
一个循环 怎么让结果全部显示出来 并能把保存到 word 或excle里面
Private Sub Command1_Click()
Dim i, j, k
For i = 1 To 33
For j = 1 To 33
For k = 1 To 33
If i + j + k = 88 Then Print i, j, k
Next k
Next j
Next i
End Sub
以这个循环
Private Sub Command1_Click()
Dim i, j, k, a, b, c
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 Debug.Print c, b, i, j, k, a
Next a
Next k
Next j
Next i
Next b
Next c
End Sub

Private Sub Command1_Click()
Dim i, j, k
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 i = 1 To 33
For j = 1 To 33
For k = 1 To 33
If i + j + k = 88 Then
'Print i, j, k '这是你的原语句
H = H + 1
xlSheet.Cells(H, L).Value = i & " " & j & " " & k
End If
Next k
Next j
Next i

Set xlSheet = Nothing: Set xlBook = Nothing: Set xlApp = Nothing
End Sub

'补充-----------------------------------
Private Sub Command1_Click()
D