April 2006
Beginner
1114 pages
98h 16m
English
It is common practice to enable or disable controls
based on what other options are selected. Controls are enabled by default. Use the control’s Enabled property to disable or reenable the control after disabling.
For example, to make the View Chart button available only after the user has clicked Get History, set the View Chart button’s Enabled property to False in the Properties window, and add this code to the cmdGetHistory_Click procedure:
Private Sub cmdGetHistory_Click( )
Dim fname As String
' Show the source worksheet.
Worksheets("VBForm").Activate
' Make sure the user entered a symbol.
If txtSymbol.Text <> "" Then
ResetWorksheet
CreateQuery txtSymbol.Text, spnDays.Value
HideUnneededCells
fname = CreateChart(imgChart.height, imgChart.width)
' Update the image control.
Set imgChart.Picture = LoadPicture(fname)
End If
' Add this to enable View Chart button.
cmdViewChart.Enabled = True
End SubWhile disabled, the control appears grayed and cannot receive user actions. You can do something similar by setting the control’s Visible property, but that is less common. Hiding and showing controls is usually reserved for complex or multistep tasks.
Read now
Unlock full access