关于VB读取07版与13版excel出现报错怎么解决,读03版正常!
Dim cn As New ADODB.ConnectionDim rs As New ADODB.Recordset
Function GETDATA()
If rs.Fields.Item(0).Value <> "" Then Text1(0).Text = rs.Fields.Item(0).Value
If rs.Fields.Item(1).Value <> "" Then Text1(1).Text = rs.Fields.Item(1).Value
If rs.Fields.Item(2).Value <> "" Then Text1(2).Text = rs.Fields.Item(2).Value
If rs.Fields.Item(3).Value <> "" Then Text1(3).Text = rs.Fields.Item(3).Value
If rs.Fields.Item(4).Value <> "" Then Text1(4).Text = rs.Fields.Item(4).Value
If rs.Fields.Item(5).Value <> "" Then Text1(5).Text = rs.Fields.Item(5).Value
End Function
Private Sub Form_Activate()
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=false;Data Source=111.xls;Extended Properties='Excel 8.0;HDR=Yes'"
cn.Open
rs.Open "select * from [sheet1$]", cn, adOpenKeyset, adLockOptimistic
Dim i As Integer
If Not rs.BOF Then rs.MoveFirst
GETDATA
Label10.Caption = rs.RecordCount
End Sub
Private Sub Command1_Click()
rs.MovePrevious
If rs.BOF = True Then
MsgBox "记录已经到第一条!"
rs.MoveFirst
End If
GETDATA
End Sub
Private Sub Command2_Click()
rs.MoveNext
If rs.EOF = True Then
MsgBox "记录已经到最后一条!"
rs.MoveLast
End If
GETDATA
End Sub
Private Sub Command3_Click()
End
End Sub