在vb6.0中读取excel数据到文本框换行问题 20
我的问题:现有一个excel文件在c:\test.xls,把第一行的数据读取到vb文本框text1中,保持excel的第一行数据到文本框中也是第一行,excel的第二行数...
我的问题:
现有一个excel文件在c:\test.xls, 把第一行的数据读取到vb文本框text1中,保持excel的第一行数据到文本框中也是第一行,
excel的第二行数据到文本框中也是第二行,依次下去,不知道文本框中表示具体某一行用什么参数,请高手指教,我的代码如下:
[size=11px]Private Sub Command1_Click()
Dim xls As Excel.Application
Dim xbook As Excel.Workbook
Dim xsheet As Excel.Worksheet
Set xls = CreateObject("Excel.application")
Set xbook = xls.Workbooks.Open("c:\test1.xls")
xls.Visible = True
Set xsheet = xbook.Worksheets(1)
Dim i, j As Integer
Dim k As Integer
Dim shuzu(1 To 10, 1 To 2)
For i = 1 To 10
For j = 1 To 2
shuzu(i, j) = Cells(i, j)
Text1.Text = Text1.Text & shuzu(i, j)
Next j
Next i
xbook.Close
End Sub
运行后文本框中的文字没有换行,请高手指教
多谢!! 展开
现有一个excel文件在c:\test.xls, 把第一行的数据读取到vb文本框text1中,保持excel的第一行数据到文本框中也是第一行,
excel的第二行数据到文本框中也是第二行,依次下去,不知道文本框中表示具体某一行用什么参数,请高手指教,我的代码如下:
[size=11px]Private Sub Command1_Click()
Dim xls As Excel.Application
Dim xbook As Excel.Workbook
Dim xsheet As Excel.Worksheet
Set xls = CreateObject("Excel.application")
Set xbook = xls.Workbooks.Open("c:\test1.xls")
xls.Visible = True
Set xsheet = xbook.Worksheets(1)
Dim i, j As Integer
Dim k As Integer
Dim shuzu(1 To 10, 1 To 2)
For i = 1 To 10
For j = 1 To 2
shuzu(i, j) = Cells(i, j)
Text1.Text = Text1.Text & shuzu(i, j)
Next j
Next i
xbook.Close
End Sub
运行后文本框中的文字没有换行,请高手指教
多谢!! 展开
1个回答
展开全部
我把你的程序改了改。注意要把text1设置为允许多行输入的,否则还是看不出效果来。
Private Sub Command1_Click()
Text1.Text = ""
Dim xls As Excel.Application
Dim xbook As Excel.Workbook
Dim xsheet As Excel.Worksheet
Set xls = CreateObject("Excel.application")
Set xbook = xls.Workbooks.Open("c:\test1.xls")
xls.Visible = True
Set xsheet = xbook.Worksheets(1)
Dim i, j As Integer
Dim k As Integer
Dim shuzu(1 To 10, 1 To 2)
For i = 1 To 10
For j = 1 To 2
shuzu(i, j) = xsheet.Cells(i, j)
Text1.Text = Text1.Text & shuzu(i, j)
Next j
Text1.Text = Text1.Text & Chr(13) & Chr(10)
Next i
xbook.Close
End Sub
Private Sub Command1_Click()
Text1.Text = ""
Dim xls As Excel.Application
Dim xbook As Excel.Workbook
Dim xsheet As Excel.Worksheet
Set xls = CreateObject("Excel.application")
Set xbook = xls.Workbooks.Open("c:\test1.xls")
xls.Visible = True
Set xsheet = xbook.Worksheets(1)
Dim i, j As Integer
Dim k As Integer
Dim shuzu(1 To 10, 1 To 2)
For i = 1 To 10
For j = 1 To 2
shuzu(i, j) = xsheet.Cells(i, j)
Text1.Text = Text1.Text & shuzu(i, j)
Next j
Text1.Text = Text1.Text & Chr(13) & Chr(10)
Next i
xbook.Close
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询