Advanced Calculator



I have programmed this calculate that resembles a typical calculator that consists of the number buttons, the operator buttons and some additional buttons such as the memory button and the clear button. I have tested it and it performs just as good as the Microsoft Windows's calculator.To design the interface, you need to insert 25 command buttons, and one label that functions as the display panel. The number buttons from 1 to 9 are grouped together as a control array and named as ButtonNum while 0 is a standalone command and named as Bzero. The four basic operators are also grouped together as a control array and named as Operator. Other buttons are named appropriately according to their functions. The label is named as panel

One of the most important procedures in the program is to control the display on the panel. The procedure is

Private Sub ButtonNum_Click(Index As Integer)

If Num_of_digit > 0 Then

If Num_of_digit < 30 Then

panel. Caption = panel.Caption + Right$(Str(Index), 1)

Num_of_digit = Num_of_digit + 1

End If


panel.Caption = Right$(Str(Index), 1)

Num_of_digit = 1

End If


End Sub

The Num_of_digit is a variable that is used to check the number of digits that appear on the display panel. The procedure will ensure that if the number of digits is more than one, the preceding digit will be pushed to the left and the succeeding digit will remain on the right. However, if the number of digits is zero, the digit clicked will just appear on the rightmost position of the panel.

The Interface:

If you like to have the complete source codes of this calculator, please download the source codes (plus all other source codes in this tutorial) by donating $2.00 . 


[Back to Game Page] [Back to Tutorial Page]