I'm trying to construct a userform that has fields which, when filled, form an equation. Each field is a separate part of the equation and the number of parts is variable, thus I've had to write code creating the necessary number of controls for any given equation. This I've written at the Userform_Initialize() event.
What I'd like to do is have the equation show up as each part is entered. My problems is that I need to modify the equation each time one of the fields is changed. I know how to use the TextBox_change() event for a control that is already on the Userform, but my problem is that at the time of initialization, I've created an array of controls (e.g. Equationparts(1 To 10)) and now I can't reference them in any way that's recognizable to form an event Sub (i.e. Sub Equationsparts(1)_Change() doesn't work).
I hope I'm making sense. . . .
Alternatively, I could create controls that aren't in an array, avoiding the problem of the parenthetical array-referencing which apparently doesn't work in defining events, but I don't know how to create a variable number of controls that are uniquely named. Is there a way of creating objects that have a name that includes a variable (e.g. Set object"c" = Userform.Controls.Add("Forms.textbox.1"
where "c" is an integer variable? In other words, can I write a For loop with a variable number of iterations, say i, and then have "i" somewhere in the name of a new object created within the loop?
Any help much appreciated!
What I'd like to do is have the equation show up as each part is entered. My problems is that I need to modify the equation each time one of the fields is changed. I know how to use the TextBox_change() event for a control that is already on the Userform, but my problem is that at the time of initialization, I've created an array of controls (e.g. Equationparts(1 To 10)) and now I can't reference them in any way that's recognizable to form an event Sub (i.e. Sub Equationsparts(1)_Change() doesn't work).
I hope I'm making sense. . . .
Alternatively, I could create controls that aren't in an array, avoiding the problem of the parenthetical array-referencing which apparently doesn't work in defining events, but I don't know how to create a variable number of controls that are uniquely named. Is there a way of creating objects that have a name that includes a variable (e.g. Set object"c" = Userform.Controls.Add("Forms.textbox.1"
Any help much appreciated!