0% found this document useful (0 votes)
106 views2 pages

Codigos de Visual

This code defines a class that connects to an Access database and allows a user to search for records by entering a key into a text box. It contains functions to query the database and check if a match is found. There are also event handlers for buttons that append numbers/characters to the text box, clear it, or perform the search and open another form if a match is found.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views2 pages

Codigos de Visual

This code defines a class that connects to an Access database and allows a user to search for records by entering a key into a text box. It contains functions to query the database and check if a match is found. There are also event handlers for buttons that append numbers/characters to the text box, clear it, or perform the search and open another form if a match is found.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Imports System.Data.

OleDb
Public Class Form1
Dim cn As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data
source=datadirectory\base1.accdb")
Public Function ask()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
cn.Open()
Dim da As New OleDbDataAdapter("select * from Tabla1", cn)
da.Fill(dt)
For Each DataRow In dt.Rows
If TextBox1.Text = DataRow(0) Then
cn.Close()
Return True
End If
Next
cn.Close()
Return False
End Function
Sub buscar()
Dim CMD As New OleDb.OleDbCommand("Selec * From Tabla1 where clave= '" &
TextBox1.Text & "'", cn)
Dim dr As OleDb.OleDbDataReader
cn.Open()
dr = CMD.ExecuteReader
If dr.Read Then
TEXBOX2.TEXT = dr(1)
Else
MsgBox("Error")
End If
cn.Close()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button6.Click
TextBox1.Text = TextBox1.Text & "1"
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button9.Click
TextBox1.Text = TextBox1.Text & "2"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
TextBox1.Text = TextBox1.Text & "3"
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click
TextBox1.Text = TextBox1.Text & "4"
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button8.Click
TextBox1.Text = TextBox1.Text & "5"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
TextBox1.Text = TextBox1.Text & "6"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
TextBox1.Text = TextBox1.Text & "7"
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button7.Click
TextBox1.Text = TextBox1.Text & "8"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
TextBox1.Text = TextBox1.Text & "9"
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button10.Click
TextBox1.Text = TextBox1.Text & "0"
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button12.Click
TextBox1.Text = ""
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button11.Click
Call buscar()
If ask() = True Then
Form2.Show()
Else
MsgBox("error")
End If
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TEXBOX2.TextChanged
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PictureBox1.Click
End Sub
End Class

You might also like