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

Tuesday, February 8, 2011

Visual Basic 6.0 - Session 5


•  Add a new menu heading Selections with two subheadings, Binary Selection and Multiway Selection.  

Visual Basic 6.0 - Session 4

Create a calculator that can add, subtract, multiply and divide two numbers given by the user. A possible solution might use two input boxes (txtOne and txtTwo) and a label to display the answer (lblAnswer).

Declare  variables:
      dblNo1 As Double
      dblNo2 As Double
      dblAnswer As Double
      intError As Integer

Visual Basic 6.0 - Session 3

Message and Input Boxes
Message and input boxes are intrinsic functions in Visual Basic 6.0 which allow the end
user to interact with the program.

Follow the instructions Add new form to menu  at the end of session 1  to create a new form with a menu heading on the main form.  Call this “Message and Input Boxes”
•  Make the Form.Caption = “Message and Input Boxes”
•  Put a label on the top of the form  “Computer Conversation”.  Underneath have a command button with the caption “Talk to me!”  Name the command button cmdTalk.
•  Double click the command button to add the following code sequence.

Monday, February 7, 2011

Visual Basic 6.0 - Session 2

1. Open a new form and change its name to ColourChanger.  Place the following objects on this form.
  •  A heading label2 (Caption = Colour Changer)
  •  3 horizontal scroll bars (Set the max value property of all three to 255)
  •  3 other labels (2red, 3Green, 4Blue)
  •  a command button to quit the form (Caption = Return)
  •  another small label5 under the button with its visible property set to false.

Visual Basic 6.0 - Session 1

•  Open VisualBasic 6.0
•  Use the file menu to open a new project with a blank form.
•  Use the properties window to set
  • Main.frm as the form name.
  • My programs as the caption.
  • BackColor to White.
  • BorderStyle to Fixed Single.
  • WindowState to Maximised.