View Single Post
 
Old 03-19-2019, 10:56 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Scotty

I usually try to make the controls as self-sufficient as possible. For instance, I would use the tag property of each text box to put the default values in. Then I could use that value to both fill the initial view and test for changes to default values. See the following code example
Code:
Private Sub UserForm_Initialize()
  Dim i As Integer, aCtl As Control
  For i = 1 To 8
    Set aCtl = Me.Controls("TextBox" & i)
    aCtl = aCtl.Tag
  Next i
End Sub

Private Sub UserForm_Click()
  Dim i As Integer, aCtl As Control
  For i = 1 To 8
    Set aCtl = Me.Controls("TextBox" & i)
    If aCtl = aCtl.Tag Then
      MsgBox aCtl.Name & " still has default value"
    ElseIf aCtl = "" Then
      MsgBox aCtl.Name & " is empty"
    End If
  Next i
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote