[size=1]Private Sub spnLines_Change()
' Change the Value of the textbox with the UpDown control's Value property.
txtLines.Text = CStr(spnLines.Value)
End Sub
Private Sub txtLines_Change()
'Make sure entry is a number, if not, beep and put in last value.
If Not IsNumeric(txtLines.Text) Then
Beep
txtLines.Text = Format(spnLines.Value, "0")
Cancel = True
'Check values are within accepted range, exit if not.
ElseIf Val(txtLines.Text) > spnLines.Max Or Val(txtLines.Text) < spnLines.Min Then
MsgBox "Number Of Lines Must Be Between 1 and 5"
' Call below procedure to enable/disable relavent form controls.
Else
spnLines.Value = Val(txtLines.Text)
DisableFormControls (txtLines.Text)
End If
End Sub
Private Sub DisableFormControls(ByVal strNumberEntered As String)
Dim ctlFormControl As Control
For Each ctlFormControl In UserForm1.Controls
If Not (Right(ctlFormControl.Name, 1) = strNumberEntered) And _
Not (ctlFormControl.Name = "txtLines") Then
If (Mid(ctlFormControl.Name, 4, 4) = "Edit") Or _
(Mid(ctlFormControl.Name, 4, 4) = "Line") Then
ctlFormControl.Enabled = False
End If
Else
ctlFormControl.Enabled = True
End If
Next ctlFormControl
End Sub
Private Sub txtLines_Enter()
' Start highlight before first character, & highlight to end of text.
With txtLines
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub[/size]