Wednesday, February 9, 2011

Visual Basic 6.0 - Session 12

Write a program that uses nested For loops to fill a 2 dimensional array and then to print out the times tables from 1 – 12 into a picture control using the syntax:

picDisplay Print (variable, [variable] ...]

with a new line for each new times table on the display.

You will definitely need to plot this one out on paper first, writing your algorithms and checking them.  To declare your variable, you need the statement:

Dim arrTables[12,12] As Integer

 

Visual Basic 6.0 - Session 11

Create a program to generate the first 20 Fibonacci numbers.  This time use a counter to control the number of iterations.  Add a Picture Box to print your results to.  Make sure the PictureBox.Font Transparent = False, AutoRedraw = True and that the BackColor is different from the ForeColor.  Use the following code to help you.
Dim FibNumber As Integer,FibNext As Integer,Counter As Integer
FibNumber=0
FibNext=1
Picture1 Print "Ist20FibonacciNumbers"
Do While Counter<20
  Picture1 Print FibNumber&","
  Picture1 Print FibNext&","
  FibNumber=FibNumber+FibNext
  FibNext=FibNext+FibNumber
  Counter=Counter+2
  If Counter=10 Then
     Picture1 Print
     ‘Thiscreatesanewline
  EndIf
Loop
Write an IPO chart and the algorithm in pseudocode and as a flowchart.

Visual Basic 6.0 - Session 10

Use a new function Rnd() to generate a random number.  Write an application on a new form to generate a random number between 1 and 6 to simulate the rolling of a dice.  Your form will need a large picture box with the Autosize property set to true and a command button with the following code behind it.

Visual Basic 6.0 - Session 9

In this tutorial, we look at writing code containing the 5 basic control structures.
•  sequence
•  binary selection
•  multiway selection
•  pre-test iteration
•  post-test iteration

The IPO chart and pseudocode algorithm for finding the average of some numbers entered from the keyboard, using a post-test loop, might look like this:

Visual Basic 6.0 - Session 8

Create a new form and link to iteration — pre-test (- Count the beeps) on the Main menu.  Add a text box and a command button.  Put a label above the text box asking the user to input a number between 1 and 10.  When the user clicks the command button, check the textbox for a valid number and issue an error message if the number isn’t inside the expected range.  If the number is valid, use Do While    ……    Loop to issue that
number of beeps. Name your form frmBeeper.

Visual Basic 6.0 - Session 7

A control array is a set of multiple controls of the same type with the same name (often created by using the Copy and Paste command).  You may have encountered this already in adding radio buttons or check boxes to your form.  Individual controls within the array are distinguished by having different Index property values.  So, if you created a control array of option buttons called optChoice, the Click event procedure might look like this:

Visual Basic 6.0 - Session 6

1. The post office has the following charges for parcels based upon different weights.


Parcels which are heavier than 500 gms are calculated by weight*0.02