怎样在vb中将计算结果输出到excel表格中

2024-11-27 04:36:56
推荐回答(2个)
回答1:

建Command1,Text1,Text2,Text3.代码如下。
注:源程序已经发到邮箱,请查收。
=================
Option Explicit
Dim xls As Object, sht As Object
Private Sub Command1_Click()
Static i As Integer
i = i + 1
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
sht.Cells(i, 1).Value = Text3.Text
End Sub

Private Sub Form_Load()
Set xls = CreateObject("Excel.Application")
Set sht = xls.Workbooks.Add.Sheets("Sheet1")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Command1.Caption = "="
xls.Visible = True
End Sub

回答2:

运营官太强了, 以后学生都不用做作业了.