Hi I'm pretty hopeless at VB, basically I have lots of similar code in my program.
I'm pretty sure there must be a way to minimize the repeating of the same code.
The main culprits are two subs with If statements.
I'm pretty sure there must be a way to minimize the repeating of the same code.
The main culprits are two subs with If statements.
Code:
Private Sub ValidateData()
Dim data As Boolean
data = IsNumeric(txttemp.Text)
If data = False Then
MessageBox.Show("Temp Data is invalid")
txttemp.Text = ""
End If
data = IsNumeric(txtheartrate.Text)
If data = False Then
MessageBox.Show("Heart Rate Data is invalid")
txtheartrate.Text = ""
End If
Code:
Private Sub paddy()
If txttemp.TextLength < 4 Then
txttemp.Text = txttemp.Text.PadLeft(4, "0")
End If
If txtheartrate.TextLength < 3 Then
txtheartrate.Text = txtheartrate.Text.PadLeft(3, "0")
End If