Is not case sensitive
Logics and operations are unified
It support the use of objects
Can create executable files.
Statements are terminated by keyword "End if"
Data Types;Are set of data with values having predifined characteristics.
Variables;Is a named memory location used to store values but keep on changing during program execution
Constants;Is a named memory location that stores values but do not change during program execution.
Identifies;Are names given by. Programmers to objects in a program.
It should be less than 255 characters.
It should not be a keyword or reserved word.
It should always begin with an alphabet.
It should not contain blank spaces.
It should be unique within given slope.
Visual basic is said to be event driven because;
All or majority of the code happens as a result of something else,which is an event.
A message box has three parts namely;
Prompt;Is a message of a message box.
Tittle;Is the tittle of the message box.
Helpfile and Context;Is where in a helpfile a user can find help from that message box.
Parts of the input box:
title Prompt;This is the message that input box has.It tells the user what the program wants them to input.
s:
Data Types;Are set of data with values having predified characteristics.
Variables;Is a named memory location used to store values but keep Post titlechanging during program eecution
Constants;Is a named memory location that stores values but do not change during program eecution.
Identifies;Are names given by. Programmers to objects in a program.
Data Types in Visual Programming
Avariable:
Is a named memory location that holds data
It can hold only one data type i.e String,Integer.A program may have as many variables as you need but it has to be declared before being used.We use Dim statement to declare variables.
Formattof declaring variables using a Dim
Dim Var Name As Data type i.e
Dim curcost As currency.
Dim strsurname as String
Function;Is a segment of codes that accepts one or more arguments and return a 0 results.
Visual basic include many build in functions.
Intrinsic functions;Some perform basic mathematical task while others manipulate string data such as converting text to upper or lower case letters.
Arguments;Is a value passed to a function so that a function has data to work with.
N/BProperty of a label are;Name,Caption and color.Label caption(object property)="Welcome to visual basic"(option property).
An object;Is anything that appears on the screen.It has a set o properties and each property has a set of values.
Events;Are things that happen on the screen.
Procedure;Is a group of statement design to perform a specific task.
Quiz
Design a form containing 2 text box so that when you click on command button copy,the text is copied from 1st to 2nd text box.
Hint 1label,1 text box and 1 command.
Private sub command-click()
Text2.text=Text1
Texr2.font size=28
End sub.
Option button;
It is used only as a group of buttons.When the user select one of them,the others are deselected automatically.The option button usually takes click event.
Quiz
Design a form with 3 option button,Red,Green and blue,such that when we click on option button, the color of the form colors to red,green and blue respectively.
Hint;
3 option buttons with 3 labels.
Form.back color=vb green
End sub.
Private sub option-click()
Form1.back color=vb red
End sub.
Private sub option-click()
Form1.back color=vb blue
End sub.
De sine a form with one text box and three check boxes such that when you click on the check boxex the following is done.Change text to bold,italics and underline.
text.font bold=check2.value
End sub.
Private sub check2.click()
Text.font italic=check2.value
End sub.
Private sub check3.click()
text.font underline=check3.value
End sub.
Timer
It returns the time in milliseconds.It may be used to measure execution time of codes(program efficiency)
Design a form to display "Aplied Science"such that when you click on "command button"start the color of the applied science change randomly every second.
Hint;Timer,label,command button.
The function "Cint"is used to convert to integer and "Rnd" is used to generate Armando number in a range(0-1).
Solution;
t=Rnd*15
label1.fore color=qbcolor(Cint(t))
End sub.
Private sub command1.color check()
timer.Enabled=True
End sub.
Write a program to move text excellent from textbox to msgbox and change the color of the text.After click on command button display.
Hint;
1 textbox,1 command button.
text1.back color=qbcolor(g)
text1.text=" "
End sub.
Description
Absolute(abs)(x) Absolute of x
Squre(sqr)(x)Squreroot of x
Integer(int)Integer of x
Exponential(exp)(x) Exponential of
Fixation(x)Take integer part
Sin (x)Cos(x)Tan(x)=0Trigometric functions
Log(x)Natural logarithms
Len(x)Number of characters of variable x
Lcase(x)Change text x to upper case
Ucase(x)Change text x to lower case
Cint(x)Convert x to integers
ClongxConvert x to long
Cdbl(x)Convert x to double precission
Cstr(x)Convert variable x to string
val(x)Convert string x to numerical value.
Write a program to enter any text and compute its length.
Hint;
1 label,1 textbox and 1 command button.
Private sub command1_click()
S=input box("Enter String")
L=len(s)
Text1.text=(str(l)
End sub.
Write a program to add and subtract 2 integer numbers.Use messagebox for outputting.
Hint;
2 labels,2 text boxes and 2command buttons.
Private sub command1_click()
x=val(text1.text)
y=val(text2.text)
z=x+y
msgbox("Addition results="&z)
End sub
Private sub command2_click()
x=val(text1.text)
y=val(text2.text)
z=x-y
msgbox("subtraction results="&z)
End sub
dim x,y,z AS integer
Private sub command1_click()
x=val(text1.text)
y=val(text2.text)
z=x+y
Text3.text=z
A program that compute a function sine,cosine,integer value,squre and the absolute value.
Hint1 text box and 6 command buttons.
Private sub command1_click()
x=val(text1.text)
y=Abs(x)
Text1.text=Cstr(y)
End sub
x=val(text1.text)
y=sqr(x)
text1.text=Cstr(y)
End sub
Private sub command3_click()
x=val(text1.text)
y=int(x)
text1.text=Cstr(y)
End sub
Private sub command4_click()
x=val(text1.text)
y=sin(x*3.114159/180)
text1.text=Cstr(y)
End sub
A program that allows the name of a student and two marks of any subjects by input box then compute the average and display the name and average in two labels.
Hint
two labels and one command button.
Private sub form1_load
x=input box("Enter your name")
y=input box("Enter the 1st marks")
z=input box("Enter the 2nd marks
Private sub command1_click
Av=val(y0/2+val(z)/2
Lbel2.caption=Av
End sub.
Hint
Area=1/2*b*h
Two labels,one text box and one command button.
Private sub command1_click()
b=val(text1.text)
h=val(text1.text)
a=0.5*b*h
msgbox("area="&a)
End sub.
Ladel.caption=Time value(now)
Label2.caption=Date value(now)
End sub