1. Simple Controls
A. Write a program to take the price of raw materials A & B from the user and hence compute the cost price. Show the same to the user in a box and then calculate the selling price with 20% profit added to the cost price. Show the same in a separate box. Use four text boxes and name them properly
B. Now add a button to the earlier program so that you can run the calculations when the button is clicked and not at Form_Load or Form_Click. If you dont know about buttons ... look below
C. Now add a check box (called AddProfit) to the earlier code / form. Hence change your code so that, it will add the profit to the cost price, only it the AddProfit box is checked (i.e. there is a tick mark in it) else, it should simply show the cost price as selling price
About Buttons:
Use the toolbox you see on the left, OR open the same from the spanner & hammer icon on the top. Click on the plain rectangle below the "A" icon and to its right. Then drag and drop on the form to make the button. In the code window create a code for the button (which by default is called button1) and for the event Click, .... i.e.
Private Sub Button1_Click()
End Sub
About Check Boxes:
The toolbox has a symbol of a box with a tick mark. Click on it and then drag and drop on the form to create the control (i.e. checkbox). If while the code is running, the box is clicked upon and it is blank, it takes the value as true and shows a tick mark. If the box already has a tick while the program is running, it will become blank and its value becomes false. You can use the value as follows in your code:
IF AddProfit = True THEN .......
2. Diagnosing Loops and Branches
How will the following program work. Go over each line step-by-step like the debug feature of VB and fill up the table below with the values of the variables as the loop goes over different iterations
For i = 1 to 7
k = 1
For j = i To i +1
k = k + j
Next j
Next i
| i | j | k |
~~~~~~~~
| 1 | 0 | 1 |
| 1 | 1 | 2 |
etc....
Comments
Post a Comment