Private Sub Command1_Click()
Dim xlApp As New excel.Application  '需引用microsoft Excel 12.0 0bject Library
Dim xlBook As New excel.Workbook
Dim xlSheet As New excel.Worksheet
Dim ends
 On Error Resume Next
 Set xlBook = xlApp.Workbooks.Open("f:/dgResult.XLS", ReadOnly:=True) '打开文件并以只读形式打开'
' xlApp.Visible = False
 Set xlSheet = xlBook.Sheets("dgResult")' 获得该工作簿的“sheet1”表
 xlSheet.Select
     ends = xlSheet.Columns(2).Find("*", SearchDirection:=xlPrevious).Row
 For Each Rng In xlSheet.Range("A2:A" & ends)
    m = m + 1
    If Rng Like Text1.Text Then
    k = k + 1
Text2.Text = xlSheet.Range("B" & m + 1) '名称'
Text3.Text = xlSheet.Range("C" & m + 1) '单位'
Text4.Text = xlSheet.Range("D" & m + 1) 
Text5.Text = xlSheet.Range("E" & m + 1) 
 End If
 Next
 Set xlSheet = Nothing
 Set xlBook = Nothing
 xlApp.Quit
 Set xlApp = Nothing
 End Sub
										
					
	
	
	
	      
 
											







