Designing a Calculator in Visual Basic 2013 Part 2

In our previous post, we have shown you the interface of the calculator and the code that can display numbers on the panel. In this article, we will delve into the code that makes calculator in visual basic 2013 works.

Let’s review the first part of code that displays numbers on the display panel when he user click on the number buttons.

Private Sub Btn1_Click(sender As Object, e As EventArgs) Handles Btn0.Click, Btn1.Click, Btn2.Click, Btn3.Click,
Btn4.Click, Btn5.Click, Btn6.Click, Btn7.Click, Btn8.Click, Btn9.Click

If LblPanel.Text = “0” Then LblPanel.Text = “”
LblPanel.Text += sender.text

End Sub

To display numbers on the code, we just need to write one block of code for all the number buttons instead of one block of code for each and every button. The method is by using the sender object and by placing click event for all the buttons after the Handles keyword, separated by commas.

The meaning of sender As Object is the object that responses when the user clicks on a particular button. For example, if the user clicks on Btn2 number button, the sender is Btn2. The action is to display the text of the sender on the display panel, in this case it is 2 if the text on the display button is 0, otherwise the digit 2 will be placed in front of the previous digit.

We shall continue our discussion in next article….

Google+Sina WeiboGoogle GmailYahoo MailPrintLinkedInPinterestTumblrQQShare

Designing a Calculator in Visual Basic 2013 Part 1

We have shown you how to design a calculator in Visual Basic 6. Now we wish to demonstrate how to create a calculator in Visual basic 2013. First of all, design the interface of the calculator as shown below;
calculatorFirst, Insert a label to be used as display panel for the calculator. Next, insert ten number buttons and change the text from 0 to 9. Finally, insert the buttons to be used as arithmetic operators and other functions such as backspace.

Now, we shall show you how to display the numbers on the display panel. Write the following code to response to clicks from the user on the number buttons. Write the code by double clicking on any number button, here we use the button with number 1.

Private Sub Btn1_Click(sender As Object, e As EventArgs) Handles Btn0.Click, Btn1.Click, Btn2.Click, Btn3.Click,
Btn4.Click, Btn5.Click, Btn6.Click, Btn7.Click, Btn8.Click, Btn9.Click

If LblPanel.Text = “0” Then LblPanel.Text = “”
LblPanel.Text += sender.text

End Sub

This code with display numbers on the display panel.

We will show you how to write other codes in next article.

 

 

Google+Sina WeiboGoogle GmailYahoo MailPrintLinkedInPinterestTumblrQQShare

Creating a Drawing Pad using Visual Basic 6

We can create a simple virtual drawing pad using Visual Basic 6 .In this program, the user just needs to fill in coordinates of the starting point and the ending point and chooses a color in order to draw the required shape. If he or she forgets to fill in the coordinates or chooses a color, he or she will be prompted to do so.

To create the drawing pad, you need to insert a common dialog control, a picture box, four text boxes , six command buttons and the necessary labels. The function of the common dialog control is to assist the users to choose colors. The text boxes are for the user to enter the coordinates and the picture box is to display the pictures drawn.

Read More

Google+Sina WeiboGoogle GmailYahoo MailPrintLinkedInPinterestTumblrQQShare