General
Purpose Packages
Automated
Systems
Commercial Data
Processing
Computer Systems
Hardware
Computer Systems
Software
Programming Course
Arrangements

Common Syntax

 

   
What do you want to do? Syntax Examples
   

A

Top

   
   
B

Top

   
   
C

Top

Clearing a ListBox ListBox1.Items.Clear Clears the contents of a ListBox
Creating a Comment 'Comment - use an apostrophe at the begriming of the line. The computer will ignore whatever comes after it on the same line. It should appear as green.
   
D

Top

Declaring Variables - Do this at the very top of the program just below Public Class Form1(). Dim Number as Integer. - Creates a variable called Number that stores whole numbers, so that values like 3.33, 104.75 are stored as 3 and 104.
Dim Number as Decimal - Creates a variable called Number that can hold decimal numbers, so that values like 3.33 and 104.75 are stored as 3.33 and 104.75.
Dim aString as String - Creates a variable called aString that can store text.
   
E

Top

   
   
   
F

Top

   
G

Top

Grabbing the contents from a TextBox and placing in a variable Number = TextBox1.Text, Name = TextBox1.Text
Takes the contents of TextBox1 (numbers or text) and stores in a variable.
   
H

Top

   
   
I

Top

Using Input Boxes Name = InputBox("What is your Name?") - Displays a box with a question. What the user then enters is stored in a variable called Name.
Using Message Boxes MesgBox("You entered " & Name) - Displays a box with a statement and the contents of the variable called Name.
   
J

Top

   
K

Top

   
L

Top

Loops - repeats a number actions. There are different types of Loops.

For... Next Loops - repeats instructions a set number of times. It looks like this
For counter = 1 to 10
ListBox1.Items.Add(message)
Next

If the variable message holds the text "I Like Computing" then this loop will be printed out in the ListBox 10 times.


Do ... While Loop - will repeat instructions until a condition is met. For example:-
Do While counter <10
counter +=1
Loop

Will keep adding 1 to a variable called counter as long as the counter is less than 10.


Do .. Until Loop - similar to the previous example. Will keep repeating until a condition is met.
Do Until Number = 10
Number +=1
Loop

Will keep adding 1 to a variable called Number Until it equals 10.

Adding Items to a ListBox. ListBox1.Items.Add("The answer is " & answer) - Displayed the listbox with the text "The answer is " with the contents of the Variable called answer
   
M

Top

   
   
N

Top

   
   
O

Top

Creating Objects. Find the object you want, Label, ListBox, Command button, TextBox in the Tool sidebar and drag onto your form. Rearrange them to your liking.
   
P

Top

   
Q

Top

   
R

Top

   
   
S

Top

Setting a string variable to empty. Dim Name as string - sets up a string variable.
Name = String.Empty - clears or sets the Name variable to empty.
Creating a subroutine. Simples. Just write the name you wish to use in the main program with round brackets Eg. Get_Scores() and then use as part of declaration of the sub routine. eg
Private Sub Get_Scores()
score1 = TextBox1.Text
End Sub
   
   
T

Top

   
U

Top

   
V

Top

   
W

Top

   
X

Top

   
Y

Top

   
Z

Top

   
 

 

 

 


 

 

 

 

Home | S1 Topics | S2 Topics
Computing Standard Grade | Info Systems Intermediate II | Info Systems Higher | Internet Safety
Log into Glow | School Website | Contact Us