Okay this is hard to explain in words (makes it even harder to search for an answer online) but I will try to explain it below is the code I currently have:
What I would like to know if I could have something like this:
The idea is that it would select whatever textbox based on what string was sent to it to strText, so instead of having four if statement clauses I would just have one that would handle them all. So if strText = Goals then it would run txtGoals.Clear() and then txtGoals.Focus(), if it was strText = Assists it would instead run txtAssists.Clear() and txtAssists.Focus() . Thank you in advance for your help, just though I would like to learn a way to shorten the code.
Code:
Private Sub ClearFocus(ByVal strText As String)
'This sub checks to see what text box needs to be selected
'and cleared if an error occurs
If strText Is "Seasons" Then
txtSeasons.Clear()
txtSeasons.Focus()
ElseIf strText Is "Rookie Age" Then
txtRookieAge.Clear()
txtRookieAge.Focus()
ElseIf strText = "First Name" Then
txtFirstName.Focus()
ElseIf strText = "Last Name" Then
txtLastName.Focus()
End If
End SubCode:
Private Sub ClearFocus(ByVal strText As String)
'This sub checks to see what text box needs to be selected
'and cleared if an error occurs
txt(strText).Clear()
txt(strText).Focus()
End Sub