I have produced working (single user) application for a Vet friend of mine.
He has successfully used this for three years but as his client history gets larger it has slowed down.
As you see it has multiple relational tables
I used the data controls to produce a data-bound form
This is an example of the code used - Can anyone advise how I might speed this up - preferably without rewriting the entire program?
Public Class frmAnimalsFind
Dim FoundArray(30000) As Integer
Dim here As Integer
Dim Searching As Boolean = False
Public historyShown As Boolean = False
Private Sub frmAnimalFind_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.MdiParent = frm_MDIMain
Me.Top = 1
Me.Left = 1
Me.Width = 775
Me.Height = 745
Me.TblClientTableAdapter.Fill(Me._Viking_Bay_Vets___Client_DataDataSet.tblClient)
Me.TblAnimalTableAdapter.Fill(Me._Viking_Bay_Vets___Client_DataDataSet.tblAnimal)
TblAnimalBindingSource.Position = 1
End Sub
Private Sub btnFirst_Click(sender As Object, e As EventArgs) Handles btnFirst.Click
TblAnimalBindingSource.MoveFirst()
End Sub
Private Sub btnPrevious_Click(sender As Object, e As EventArgs) Handles btnPrevious.Click
TblAnimalBindingSource.MovePrevious()
End Sub
Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
TblAnimalBindingSource.MoveNext()
End Sub
Private Sub btnLast_Click(sender As Object, e As EventArgs) Handles btnLast.Click
TblAnimalBindingSource.MoveLast()
End Sub
Private Sub txtFind_TextChanged(sender As Object, e As EventArgs) Handles txtFind.TextChanged
Dim Searchname As String
Dim FoundCount As Integer = -1
If txtFind.Text <> "" Then
Searchname = UCase(Trim(txtFind.Text))
LstResults.Items.Clear()
TblAnimalBindingSource.MoveLast()
TblAnimalBindingSource.MoveNext()
Do
If InStr(UCase(AnimalNameTextBox.Text), Searchname) = 1 _
Or InStr(ID_chipTextBox.Text, Searchname) = 1 Then
FoundCount = FoundCount + 1
FoundArray(FoundCount) = TblAnimalBindingSource.Position
TblClientBindingSource.MoveLast() ' add client details to list
Do
If ClientIDTextBoxAn.Text = ClientIDTextBoxCl.Text Then
Exit Do
End If
If TblClientBindingSource.Position = 0 Then Exit Do
TblClientBindingSource.MovePrevious()
Loop
LstResults.Items.Add(AnimalNameTextBox.Text & vbTab & SurnameTextBox.Text & ", " & InitialsTextBox.Text)
End If
If TblAnimalBindingSource.Position = 1 Then Exit Do ' 1 not 0 to hide Admin Animal
TblAnimalBindingSource.MovePrevious()
Loop
If FoundCount > -1 Then
TblAnimalBindingSource.Position = FoundArray(0)
Else
MsgBox("Name/ID-Chip not found")
End If
Else
LstResults.Items.Clear()
End If
End Sub
Private Sub LstResults_SelectedIndexChanged(sender As Object, e As EventArgs) Handles LstResults.SelectedIndexChanged
TblAnimalBindingSource.Position = FoundArray(LstResults.SelectedIndex)
End Sub
End Class