StephenGKorea
New Member
- Joined
- Feb 27, 2005
- Messages
- 28
I am building a rather good size userform that now I am putting in all the bells and whistles now (i.e. idiot proof the form now)
It is getting really lengthy code-wise because I want certain things to be enabled and disabled on the form as they click on certain options.
I know I can hard code the lines but so I am trying to come up with some coding elements where I will not have to add 20+ lines of code for everytime I want to add a new feature.
Here is one of the functions that I have, There is going to be several of these:
Private Sub chkMore2_Click()
If chkMore2 = True Then
cboProtocol2.BackStyle = fmBackStyleOpaque
cboApplication2.BackStyle = fmBackStyleOpaque
txtLowPort2.BackStyle = fmBackStyleOpaque
txtHighPort2.BackStyle = fmBackStyleOpaque
txtAIS2.BackStyle = fmBackStyleOpaque
txtVer2.BackStyle = fmBackStyleOpaque
optDynamicYes2.BackStyle = fmBackStyleOpaque
optDynamicNo2.BackStyle = fmBackStyleOpaque
chkMore3.Enabled = True
cboProtocol2.Enabled = True
cboApplication2.Enabled = True
txtLowPort2.Enabled = True
txtHighPort2.Enabled = True
txtAIS2.Enabled = True
txtVer2.Enabled = True
optDynamicYes2.Enabled = True
optDynamicNo2.Enabled = True
End If
So If I click chkMore2 ... all of the 2nd elements will be editable. If I click chkMore3 ... then all of the 3rd elements will be editable, etc. etc.
So I tried to play with this code example:
Private Sub CheckBox1_Click()
If CheckBox1 = True Then
Call Changeit(1, "yes")
Else
Call Changeit(1, "no")
End If
End Sub
Function Changeit(box As Integer, yn As String) As String
With Application.WorksheetFunction
If yn = "yes" Then
.concatenate("TextBox", box).Value = "yes"
Else
.concatenate("TextBox", box).Value = "no"
End If
End With
End Function
Excel 2007 does not like the .concatenate element, I have tried other ways, but I can not seem to get anything to work or I wouldnt be asking, huh?
TIA
Stephen
It is getting really lengthy code-wise because I want certain things to be enabled and disabled on the form as they click on certain options.
I know I can hard code the lines but so I am trying to come up with some coding elements where I will not have to add 20+ lines of code for everytime I want to add a new feature.
Here is one of the functions that I have, There is going to be several of these:
Private Sub chkMore2_Click()
If chkMore2 = True Then
cboProtocol2.BackStyle = fmBackStyleOpaque
cboApplication2.BackStyle = fmBackStyleOpaque
txtLowPort2.BackStyle = fmBackStyleOpaque
txtHighPort2.BackStyle = fmBackStyleOpaque
txtAIS2.BackStyle = fmBackStyleOpaque
txtVer2.BackStyle = fmBackStyleOpaque
optDynamicYes2.BackStyle = fmBackStyleOpaque
optDynamicNo2.BackStyle = fmBackStyleOpaque
chkMore3.Enabled = True
cboProtocol2.Enabled = True
cboApplication2.Enabled = True
txtLowPort2.Enabled = True
txtHighPort2.Enabled = True
txtAIS2.Enabled = True
txtVer2.Enabled = True
optDynamicYes2.Enabled = True
optDynamicNo2.Enabled = True
End If
So If I click chkMore2 ... all of the 2nd elements will be editable. If I click chkMore3 ... then all of the 3rd elements will be editable, etc. etc.
So I tried to play with this code example:
Private Sub CheckBox1_Click()
If CheckBox1 = True Then
Call Changeit(1, "yes")
Else
Call Changeit(1, "no")
End If
End Sub
Function Changeit(box As Integer, yn As String) As String
With Application.WorksheetFunction
If yn = "yes" Then
.concatenate("TextBox", box).Value = "yes"
Else
.concatenate("TextBox", box).Value = "no"
End If
End With
End Function
Excel 2007 does not like the .concatenate element, I have tried other ways, but I can not seem to get anything to work or I wouldnt be asking, huh?
TIA
Stephen