Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) _
Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
e.Handled = True
End If
If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
e.Handled = False
End If
End Sub
c#
private void TextBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if ((Strings.Asc(e.KeyChar) < 48) | (Strings.Asc(e.KeyChar) > 57)) {
e.Handled = true;
}
if ((Strings.Asc(e.KeyChar) == 8)) {
e.Handled = false;
}
}
Topic: Information
———
Imports MySql.Data.MySqlClient
Imports System.Data
Public Class form_examination_search
Dim conn As New MySqlConnection
Dim mycommand As New MySqlCommand
Dim S As String
Dim dr As MySqlDataReader
Dim myAdapter As New MySqlDataAdapter
Dim mydata As New DataTable
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If TextBox61.Text = "" Then
MsgBox("Empty String", MsgBoxStyle.Information, "Medical Information Technology")
Else
search()
End If
End Sub
Public Sub search()
ListBox1.SelectedItems.Clear()
Dim theList As Long
Dim textToSearch As String
Dim theListText As String
textToSearch = LCase(TextBox61.Text)
For theList = 0 To ListBox1.Items.Count - 1
theListText = LCase(ListBox1.Items.Item(theList))
If theListText = textToSearch Then ListBox1.Text = textToSearch
Next
If ListBox1.SelectedItems.Count = 0 Then
MsgBox("record not found")
End If
End Sub
Public Sub textboxsearch()
conn.ConnectionString = "server=localhost;username=root;password=root;database=dbmis"
conn.Open()
S = "select * from examination_info where Name='" & ListBox1.Text & "'"
mycommand.Connection = conn
mycommand.CommandText = S
dr = mycommand.ExecuteReader()
While dr.Read()
MaskedTextBox1.Text = dr("Date")
TextBox1.Text = dr("Name")
TextBox3.Text = dr("Position")
ComboBox4.Text = dr("Department")
TextBox2.Text = dr("Year_Course")
MaskedTextBox2.Text = dr("DateofBirth")
ComboBox3.Text = dr("Age")
ComboBox1.Text = dr("Sex")
ComboBox2.Text = dr("CivilStatus")
TextBox5.Text = dr("Home_Address")
TextBox6.Text = dr("Boarding_Address")
TextBox7.Text = dr("Father_Name")
TextBox14.Text = dr("Father_Occupation")
TextBox10.Text = dr("Father_Tel")
TextBox8.Text = dr("Mother_Name")
TextBox15.Text = dr("Mother_Occupation")
TextBox17.Text = dr("Mother_Tel")
TextBox9.Text = dr("HusbandWife")
TextBox16.Text = dr("HusbandWife_Occupation")
TextBox18.Text = dr("HusbandWife_Tel")
TextBox12.Text = dr("LandladyLandlord")
TextBox19.Text = dr("LandladyLandlord_Tel")
End While
conn.Close()
End Sub
Private Sub form_examination_search_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 1 To 150
ComboBox3.Items.Add(i)
Next
conn.ConnectionString = "server=localhost;username=root;password=root;database=dbmis"
conn.Open()
S = "select Name from examination_info"
mycommand.Connection = conn
mycommand.CommandText = S
dr = mycommand.ExecuteReader()
While dr.Read()
ListBox1.Items.Add(dr("Name"))
End While
conn.Close()
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
textboxsearch()
conn.ConnectionString = "server=localhost;username=root;password=root;database=dbmis"
conn.Open()
S = "select Date,Height,Weight,HistoryandPhysical_exam,Physician_Direction from examination_exam where Name='" & ListBox1.Text & "'"
mycommand.Connection = conn
mycommand.CommandText = S
mycommand.Connection = conn
myAdapter.SelectCommand = mycommand
mydata.Clear()
myAdapter.Fill(mydata)
DataGridView1.DataSource = mydata
conn.Close()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Public Sub loadlist()
ListBox1.Items.Clear()
conn.ConnectionString = "server=localhost;username=root;password=root;database=dbmis"
conn.Open()
S = "select Name from examination_info"
mycommand.Connection = conn
mycommand.CommandText = S
dr = mycommand.ExecuteReader()
While dr.Read()
ListBox1.Items.Add(dr("Name"))
End While
conn.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ListBox1.SelectedItems.Count = 0 Then
MsgBox("There's no selected item...", MsgBoxStyle.Information, "Medical information System")
Else
MsgBox("Are you sure you want to delete the record?", MsgBoxStyle.OkCancel, "Medical Information System")
If MsgBoxResult.Ok Then
conn.ConnectionString = "server=localhost;username=root;password=root;database=dbmis"
conn.Open()
S = "delete from examination_exam where Name='" & ListBox1.SelectedItem & "' "
mycommand.Connection = conn
mycommand.CommandText = S
dr = mycommand.ExecuteReader()
While dr.Read()
TextBox61.Text = dr("Name")
End While
conn.Close()
conn.ConnectionString = "server=localhost;username=root;password=root;database=dbmis"
conn.Open()
S = "delete from examination_info where Name='" & ListBox1.SelectedItem & "' "
mycommand.Connection = conn
mycommand.CommandText = S
dr = mycommand.ExecuteReader()
While dr.Read()
TextBox61.Text = dr("Name")
End While
conn.Close()
Call loadlist()
MsgBox("Record is Deleted...", MsgBoxStyle.Information, "Medical Information System")
Else
End If
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim checkup As New form_examination_menu
main_form.Panel1.Controls.Clear()
main_form.Panel1.Controls.Add(checkup)
checkup.Dock = DockStyle.Fill
End Sub
End Class
———
https://www.oodesign.com/
———
For Jamie Holcom: i don’t know if there is a tutorial about how to do that, but it can be done, and yes, with a vb.net program or directly in your program – i have done one that . here’s some code
Dim conn1 = New MySqlConnection()
conn1.ConnectionString = “server=localhost;” & _
“user id=root;” & _
“password=” & ********
‘”;
‘Try
Dim myCommand As New MySqlCommand
Dim mySQLstr As String
Dim nume As String
Dim dialog As New OpenFileDialog
If dialog.ShowDialog = System.Windows.Forms.DialogResult.OK Then
nume = dialog.FileName.ToString
Dim fileContents As String
fileContents = My.Computer.FileSystem.ReadAllText(nume)
Try
mySQLstr = fileContents
conn1.Open()
myCommand.Connection = conn1
myCommand.CommandText = mySQLstr
myCommand.ExecuteNonQuery()
conn1.Close()
MsgBox(“Baza de date a fost creata!”)
Catch myerror As MySqlException
MsgBox(“Eroare: ” & myerror.Message)
Finally
If conn1.State ConnectionState.Closed Then conn1.Close()
End Try
End If
it will open a dialog to chose the sql file containing the structure
of course it can be automated.
ATTENTION: Do not specify the database in the connection string.
———
https://www.dreamincode.net/forums/topic/149554-how-to-create-automated-backup-files-in-vbnet-application/
———
dim query as string="Select * from table"
dim da as new oledbdataadapter(query,con)
dim ds as new dataset
da.fill(ds,"Table")
me.dgv.datasource=ds
me.dgv.datamember="Table"
ds.dispose
con.close
———
https://www.dreamincode.net/forums/topic/92266-deployment-of-database-with-the-application-software/
———
https://www.math-cs.gordon.edu/courses/cs211/ATMExample/
———
https://www.connectionstrings.com/
https://www.vkinfotek.com/connectionstring.html
———
https://www.knowdotnet.com/articles/printgriddemo.html