首先通过“工程/部件…”,添加“Microsoft Common Dialog Control6.0(sp3)”控件,表单添加“保存”对话框控件的名称为CDL。因为循环的次数太大,所以a和b的值很大,定义为双精度型(Double)。最好i的循环交数不要太大。
Private Sub Command1_Click()
Dim a As Double, b As Double, i As Integer
Dim strFile As String
a = 2
While i < 150
b = a * 2
a = b
i = i + 1
Wend
Print a
CDl.Filter = "Excel文件|*.xls"
CDl.ShowSave
strFile = CDl.FileName
Open strFile For Output As #1
Write #1, a
Close #1
End Sub