求助:VB中如何将text控件中的大量内容分别输出到excel中
我想要的效果是A1=1622.7966593992B1=973.581218414227A2=1622.34537664382B1=973.365941994068……以...
我想要的效果是A1=1622.7966593992 B1=973.581218414227
A2=1622.34537664382 B1=973.365941994068
……
以此类推。请问代码如何写,谢谢! 展开
A2=1622.34537664382 B1=973.365941994068
……
以此类推。请问代码如何写,谢谢! 展开
展开全部
'首先要将“工程-引用”中的Mic… Excel…选中
Private Sub Command1_Click()
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(App.Path & "\1.xls")
xlApp.Visible = False
For i = 1 To 10
Text1 = Text1 & Chr(13) & Chr(10) & 20 * i
Next i
a = Split(Text1, Chr(13) & Chr(10))
b = Split(Text2, Chr(13) & Chr(10))
k = 1
For Each Sz In a
xlApp.Worksheets("Sheet1").Range("A1").Cells(k, 1) = Sz
k = k + 1
Next
k = 1
For Each Sz In b
xlApp.Worksheets("Sheet1").Range("A1").Cells(k, 2) = Sz
k = k + 1
Next
xlBook.Save
ActiveWorkbook.Close
xlApp.Quit
Set xlApp = Nothing
End Sub
Private Sub Command1_Click()
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(App.Path & "\1.xls")
xlApp.Visible = False
For i = 1 To 10
Text1 = Text1 & Chr(13) & Chr(10) & 20 * i
Next i
a = Split(Text1, Chr(13) & Chr(10))
b = Split(Text2, Chr(13) & Chr(10))
k = 1
For Each Sz In a
xlApp.Worksheets("Sheet1").Range("A1").Cells(k, 1) = Sz
k = k + 1
Next
k = 1
For Each Sz In b
xlApp.Worksheets("Sheet1").Range("A1").Cells(k, 2) = Sz
k = k + 1
Next
xlBook.Save
ActiveWorkbook.Close
xlApp.Quit
Set xlApp = Nothing
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询