Public Class frmGrid3
Dim Aplicacion As Excel.Application
Dim Libro As Excel.Workbook
Dim hoja As Excel.Worksheet
Private Sub frmGrid3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
cargarLibro()
End Sub
Private Sub cargarLibro()
DataGridView1.ColumnCount = 3
DataGridView1.Columns(0).Name = "Bar Code"
DataGridView1.Columns(1).Name = "Producto"
DataGridView1.Columns(2).Name = "Precio"
DataGridView1.Columns(1).Width = 200
Aplicacion = New Excel.Application
Libro = Aplicacion.Workbooks.Open("C:\Users\miky mouse\OneDrive\ejemplo5.xlsx")
hoja = Libro.Worksheets(2)
End Sub
Private Sub frmGrid3_Closed(sender As Object, e As EventArgs) Handles MyBase.Closed
Libro.Close()
Aplicacion.Quit()
End Sub
Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
Dim bc As String
Dim dato(3) As String
If e.KeyCode = 13 Then
bc = TextBox1.Text
For i = 2 To 23
If bc = hoja.Cells(i, 1).Value Then
dato(0) = hoja.Cells(i, 1).value
dato(1) = hoja.Cells(i, 2).value
dato(2) = hoja.Cells(i, 3).value
DataGridView1.Rows.Add(dato)
End If
Next
MsgBox("enter " + bc)
End If
End Sub
End Class
No hay comentarios:
Publicar un comentario