No big deal. What could possibly go wrong ...
As usual, the on-line help for these compilers (particularly VisualBasic 6.0) is less than adequate.
Caption | Text displayed on the button face |
Cancel | When True, the click event executes when esc is pressed |
Default | When True, the click event executes when Enter is pressed |
Index | If not blank, then the button is part of a Control Array |
When I compiled the program, I got
Compile error: Procedure declaration does not match description of event or procedure having the same nameThis program had compiled fine before, but now the following code would not compile.
Private Sub UIToolBar_Next_UIButton_Click() 'Your Code Here End SubWhen I commented out this code and double clicked on the original button, the following template was produced.
Private Sub UIToolBar_Next_UIButton_Click(Index As Integer) End SubObviously, trouble shooting this was non-trivial. It turns out that when the index property is not blank, the button is part of a Control Array which shares one name for several objects and uses the index property to identify specific objects in the array. As a result, the index parameter is required for all property references and event definitions. For example, the following references a property.
ControlName(index).top = 5
As expected, I get exactly the same crystal clear error message if I delete the value of the index property but leave the index parameter in the event definition.
When you place the cursor on a button's index property and press F1, the help refers to objects in a collection (a completely different concept). Following this thread leads to multiple dead ends.
MS Access 97
Supposedly, LabelAlign is supposed to allow the control of formatting on Command Buttons ... except that the property is not available on any of the buttons. Thus, center is the only "option".
(Placed here because MS Access is based on VB.)
TButton | The standard push button. |
TBitBtn | Displays a bitmap instead of a label. |
TSpeedButton | Toggle button, may remain depressed. Can be defined in a group like radio buttons. |
TCheckBox | |
TRadioButton | Use this to add individual radio buttons to a form. The help is misleading - you can add individual radio buttons to a TGroupBox by selecting them from the Component palette. However, radio buttons are added to a TRadioGroup by editing the Items property. |
TRadioGroup | Displays a group of radio buttons. This is preferred to other methods because the ItemIndex property indicates which radio button is selected. -1 means that no buttons are selected. |
TSpinButton | Displays an up arrow and a down arrow. Set FocusControl and the focus will move to that control when the Spin Button is clicked. You write code to perform what ever action you want. Unfortunately, there is no help on this. Available on the Samples tab. |
TUpDown | Similar to TSpinButton ... except that it only works with integers. The current value is stored in Position. Can be either Up/Down or Left/Right. Set the Associate property to an edit field (TEdit), and it works without any additional code. On the Win32 tab. |
Caption | The displayed text. It is not possible to have multiple lines of text or to change the default text alignment. |
Enabled | Disables and grays out the control. |
Checked | Applies to TCheckBox and TRadioButton. |
AllowGrayed | Applies to TCheckBox. The State can be Checked, Unchecked, or Grayed Controls whether the user can generate a grayed state. Your program can do whatever. |
Caption | Text displayed on the button face |
Cancel | When True, the OnClick event handler executes when esc is pressed |
Default | When True, the OnClick event handler executes when Enter is pressed |
ModalResult | When not zero, closes a modal dialog box |
Arrows
Charset | SYMBOL_CHARSET | |
Name | Marlett | |
Caption | 3 4 5 6 | Left Right Up Down |
TSpinButton
I had a situation where 3 Spin Buttons were associated with 3 edit controls. Rather than have 6 routines to handle these, I set each FocusControl property to the associated edit control and used code similar to this.
procedure TForm1.IncrementValue(edit: TEdit; increment: real); begin edit.Text := FloatToStr(StrToFloat(edit.Text) + increment*0.01); // other code went here end; procedure TForm1.Index_SpinButton_UpClick(Sender: TObject); begin IncrementValue(TEdit((Sender as TSpinButton).FocusControl), 1); end; procedure TForm1.Index_SpinButton_DownClick(Sender: TObject); begin IncrementValue(TEdit((Sender as TSpinButton).FocusControl), -1); end;This allowed all 3 up buttons to call one routine, and the down buttons to call the other.