I am using a public validating sub to help validate the other subs. Is this the most efficient way to do this?
Public Sub Validator(sender As Object, e As EventArgs) Handles GrossRevenueButton.Click, CPTCodesButton.Click, EstablishedVisitsButton.Click
Dim validater As Integer = 0 'this is the variable that gets sent out from this sub
If MonthSelectBox.Text = "" Then
Label1.Text = "You didn't select a month!"
validater = 1
Else
Label1.Text = ""
End If
If YearSelectBox.Text = "" Then
Label2.Text = "You didn't select a year!"
validater = 2
Else
Label2.Text = ""
End If
If FilepathTextBox.Text = "" Then
Label3.Text = "You didn't select a file!"
validater = 3
Else
Label3.Text = ""
End If
If MonthSelectBox.Text.Length > 1 And YearSelectBox.Text.Length > 1 And FilepathTextBox.Text.Length > 1 Then
validater = 0
End If
End Sub
'GROSS REVENUE
Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles GrossRevenueButton.Click
Dim validater As Integer 'validater comes from the validate sub
If validater > 0 Then
Call Gross_Revenue()
Else
Label4.Text = "Something went wrong!"
End If
End Sub
'CPT CODES
Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles CPTCodesButton.Click
Dim validater As Integer 'validater comes from the validate sub
If validater > 0 Then
Call CPT_Totals()
Else
Label4.Text = "Something went wrong!"
End If
End Sub
'ESTABLISHED VISTS
Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles EstablishedVisitsButton.Click
Dim validater As Integer 'validater comes from the validate sub
If validater > 0 Then
Call Established_Visits()
Else
Label4.Text = "Something went wrong!"
End If
End Sub
Validator
method so it is not accessible outside of it. Also, the Click handlers also dimension their own instance of avalidater
variable and don't re-use it. Also, is theEstablished_Visits
method important to have listed? I don't see it in the above code. \$\endgroup\$