用VB语言编写程序读取excel
Public Sub excel1()
On Error Resume Next
Static i As Integer
If ww = 1 Then
i = i - 1
If i = 0 Then
ww = 0
i = 1
MsgBox "已是第一题!", vbExclamation, "系统提示"
GoTo eee:
End If
Set oleExcel = CreateObject("excel。 application")
oleExcel。workbooks。Open FileName:="c:\book1"
Label1。Caption = oleExcel。workshe...全部
Public Sub excel1()
On Error Resume Next
Static i As Integer
If ww = 1 Then
i = i - 1
If i = 0 Then
ww = 0
i = 1
MsgBox "已是第一题!", vbExclamation, "系统提示"
GoTo eee:
End If
Set oleExcel = CreateObject("excel。
application")
oleExcel。workbooks。Open FileName:="c:\book1"
Label1。Caption = oleExcel。worksheets("sheet2")。
cells(i, 1)
Label3。Caption = oleExcel。worksheets("sheet2")。cells(i, 2)
oleExcel。quit
Set excel = Nothing
ww = 0
Else
i = i + 1
Set oleExcel = CreateObject("excel。
application")
oleExcel。workbooks。Open FileName:="c:\book1"
Label1。Caption = oleExcel。worksheets("sheet2")。
cells(i, 1)
Label3。Caption = oleExcel。worksheets("sheet2")。cells(i, 2)
oleExcel。quit
Set excel = Nothing
If Label1。
Caption = "" Then
MsgBox "已是最后一题!", vbExclamation, "系统提示"
End If
End If
eee:
End Sub
这是一个子程序,你调用即可。
收起