I have a UserForm with a large number of similarly named textboxes. A DARTS Scoring System.
In fact, I've created a userform that mostly duplicates the SpreadSheet function
Using a spreadsheet is, I know, by far the best for this, but I was curious to see
if it was not only feasible but primarily useful. Situationally, giving a half-inebriated group of players
control of a complex program like Excel, is inviting all sorts of disasters.
Recreating it in UserForm style eliminates most, if not all of their ability to "fiddle", so to speak.
At the moment my fully working solution is as follows:
As you can see from the code, I've used a single handler for each Control (TextBox) clicked.
the 72 controls indicated are but the first of 8 groups of such TextBoxes.
At the moment, they only handle a single event, the AfterUpdate
Ideally, I need 3 events (OnFocus / AfterUpdate / LostFocus):
OnFocus: Change BackColor/ForeColor - (Highlights the ActiveControl)
AfterUpdate: this is handled by the TEAMSSum Function)
LostFocus: Revert BackColor/ForeColor - (de-Highlights the ActiveControl)
What I was hoping for was a single routine that could handle all of these controls
or, alternatively, a best-practice method to handle them.
Perhaps something like:
the Function TEAMSSum could be used as a container for the proposed routine, as all the Subs call it. (it sums the values of the textboxes)
so the flow would be something like IdentifyActiveControl>HighlightActiveControl>UseInput>De-HighlightActiveControl>IdentifyNextActiveControl ...
Any and all suggestions, help or advice welcomed
In fact, thank you, in advance, for even reading this post
Bruce54
In fact, I've created a userform that mostly duplicates the SpreadSheet function
Using a spreadsheet is, I know, by far the best for this, but I was curious to see
if it was not only feasible but primarily useful. Situationally, giving a half-inebriated group of players
control of a complex program like Excel, is inviting all sorts of disasters.
Recreating it in UserForm style eliminates most, if not all of their ability to "fiddle", so to speak.
At the moment my fully working solution is as follows:
Code:
Private Sub TextBox1_AfterUpdate()
TEAMSSum
End Sub
Private Sub TextBox2_AfterUpdate()
TEAMSSum
End Sub
. . . . . .(same pattern up to ...)
Private Sub TextBox72_AfterUpdate()
TEAMSSum
End Sub
As you can see from the code, I've used a single handler for each Control (TextBox) clicked.
the 72 controls indicated are but the first of 8 groups of such TextBoxes.
At the moment, they only handle a single event, the AfterUpdate
Ideally, I need 3 events (OnFocus / AfterUpdate / LostFocus):
OnFocus: Change BackColor/ForeColor - (Highlights the ActiveControl)
AfterUpdate: this is handled by the TEAMSSum Function)
LostFocus: Revert BackColor/ForeColor - (de-Highlights the ActiveControl)
What I was hoping for was a single routine that could handle all of these controls
or, alternatively, a best-practice method to handle them.
Perhaps something like:
Code:
With ActiveControl
.ForeColor = vbYellow
.BackColor = vbRed
End With
TEAMSSum (mostly formatting and calculations) calls a Function that accepts only Numeric and decimal input.
With ActiveControl
.ForeColor = vbBlack
.BackColor = vbWhite
End With
the Function TEAMSSum could be used as a container for the proposed routine, as all the Subs call it. (it sums the values of the textboxes)
so the flow would be something like IdentifyActiveControl>HighlightActiveControl>UseInput>De-HighlightActiveControl>IdentifyNextActiveControl ...
Any and all suggestions, help or advice welcomed
In fact, thank you, in advance, for even reading this post
Bruce54