PKisielewski
07-28-2009, 02:52 PM
I tried to figure this one out and I have reviewed other posts but I have not come up with the answer to my Question. My Question is “How to incorporate arrays in the ActiveX object's names to reduce redundant code”.
I have a Word document (Word 2002)which consists of several ActiveX text boxes that begin with the same name with a number on the end (ex: txt_sev_des1, txt_sev_des2, txt_sev_des3......) I am wanting to use an array to eliminate redundant coding since I am using the same code for each text box. The following is the code for one of the text boxes. Since I have 4 text boxes identical how can I consolidate the code so that I can use just one Sub Routine instead of 4.
Sub txt_sev_des1_Change()
If txt_fin_prod1.Value = "" Then ‘ Checks to make sure user typed in amount if not - exits routine
Exit Sub
Else ‘ Totals are calculated into the final risk field
txt_fin_risk_des1.Value = txt_fin_prob_des1.Value * txt_sev_des1.Value
End If
End Sub
Thanks in advance for your help.
I have a Word document (Word 2002)which consists of several ActiveX text boxes that begin with the same name with a number on the end (ex: txt_sev_des1, txt_sev_des2, txt_sev_des3......) I am wanting to use an array to eliminate redundant coding since I am using the same code for each text box. The following is the code for one of the text boxes. Since I have 4 text boxes identical how can I consolidate the code so that I can use just one Sub Routine instead of 4.
Sub txt_sev_des1_Change()
If txt_fin_prod1.Value = "" Then ‘ Checks to make sure user typed in amount if not - exits routine
Exit Sub
Else ‘ Totals are calculated into the final risk field
txt_fin_risk_des1.Value = txt_fin_prob_des1.Value * txt_sev_des1.Value
End If
End Sub
Thanks in advance for your help.