文件名称:VB读取EXCEL 编辑,
文件大小:39KB
文件格式:DOC
更新时间:2014-07-13 06:06:18
VB编程
VB,读EXCEL。转,不是本人编写的!在vb读取excel中的数据并在窗体上显示 Public ExcelTable As Workbook 'excel 工作表对象 Private TextBoxA() As Control '以编辑框为基础动态构造数据网格 Private FormWidth As Integer '窗体宽度 '以下子程序是用来建立数据网格 Sub CreateGrid(No, Data) For i = 1 To CInt(UBound(Data, 1)) For j = 1 To CInt(UBound(Data, 2)) Set a = Form1.Controls.Add("VB.TextBox", "textbox" & CStr(i) & CStr(j) & CStr(No)) ReDim TextBoxA(1 To i, 1 To j) '重新定义动态数组! Set TextBoxA(i, j) = a With TextBoxA(i, j) '设置文本框属性 .Text = Data(i, j) .Visible = True .Height = 200 .Width = 500 .Top = .Height * (i - 1) .Left = .Width * (j - 1) + FormWidth End With Next Next End Sub