Front end form programming in visual basic

Programming in form:-

The form is the platforms for the controls. There are many objects and controls for programming.

(Form)

Control:-

It is the term to identify the label, textbox, command etc.

Object:-

It is the term used to denote the controls and property box, form, detail like big form of the control.

Property:-

The property means the characteristic of the controls that identify the controls’ characters. Properties are used to pass the different values through the codes.

The properties are in the property box.

Some properties are:-

Color,height, width,name, Visible, left, top, caption, etc.

Toolbox:-

It contains the control like textbox, label, command button etc.

Event:-

It is the action that force the programme to execute.

Events are:

Click ,double-click, enter, mouse down, mouse over ,gotfocus,lostfocus etc.

The event driven program:-

The program that run by event or that is responsible on every event is the event driven program.

The every action is executed by the event. So the code is also written in the event procedure.

Basic controls:-

The basic controls are label, text box, command button those are fundamentally used while programming in all the application mostly .

Label:-

It is used to display the caption or display output . i. e. used to write the title.

Properties of label:

Caption:-used to write the title.

Forecolor:-used to set the font color.

Fontname:-used to set the font name.

Name:-used to give the particular name of the control to use in the code.

Events:-

The common events used in the label are:-

Onclick:-when we click on the label.

Ondblclick:-on the double click of mouse.

On mouse down:-when we press down the mouse.

On mouse move:-when we move the mouse on the label.

On mouse up:-when we release the mouse after the down.

Textbox:-

It is used to input and display (output )the result. It has the default label.

Properties of the text box:-

Name:-used to write the particular name.

Forecolor,backcolor:For font color and backcolor.

Value:-used to store the given value.

Events of the text box:-

Some common and mostly used events are:-

On gotfocus:when the box get focus.

On lostfocus:when the box lost focus.

On click:when we click on it with mouse.

On key up:when the key is upped .

On keypress:when we press key up and down .But to with it we need the keyascii code.

On change:-when something is done on it.

Command button:-

It is the control used to instruct or give command to execute the output.

Properties of Command button:-

Caption:Used to write down the title.

Forecolor:set the forecolor.

Name:-The name of the control used in code.

fontname :set the fontname,style etc.

Events:-

Some common events are:-

Click:-to work on click.

Dblclick:-to work on double click.

Keydown:To work on keydown.

Keypress:To work on keypress with keyascii code.

Programming sequence:-

1. Define the subject of the program.

2. Design the program preparing plan in the copy and design in the form in computer using controls.

3. Set the properties.

4. Create the event procedure then write down code within the event procedure in the code window.

Naming to control

Control prefix example

Label lbl lblresult

Textbox txt txteng

Commandbutton cmd cmdok

Creating event procedure:-

1. determine the control and event.

2. select the control and open the property box.

3. click on event tab.

4. click on any event.

5. select the event procedure.

6. click on button.

7. now write down the code within the event procedure.

Project-1:-

Create a program that Find out the total from given quantity and rate.

Solution:-

Project name:-Calculator.

Given:-Quantity, rate

To find:-Total

Output:Total=quantity*rate

Property setting:-

Set the property after designing

Code:-

Pseudo code:-

The pseudo code is like rough code that helps to write the basic easily.

Pseudo code of the above problem:

With in event procedure

Assign

Output

Example:-

Command button_onclick

Qty=txtqty

rate=txtrate

total=qty*rate

txttotal=total

End sub

Basic language:-

Private Sub cmdclik_Click()

Dim intqty As Integer

Dim intrate As Integer

intqty = txtqty.Value

intrate = txtrate.Value

txttotal.Value = intqty * intrate

End Sub

Project -2:-

Create a mark ledger from the given subjects English,nepali, sciences, math and computer and total ,percentage and result as well as division.

Important Note:-

The code is written in the event procedure on the principal of input and output.

Returning to the design view:-

Click on Microsoft access view icon.(shift+f7)

Running program or viewing in form view:

Press F5 or click on the form view.

Getting control name easily:-

Write me and dot(.) or write first name and press ctrl+space.

Passing value in control:-

Control+property=value

Color:-

There are different types of color functions to use in code. The control’s back and fore color property contains the following color expressions.

Vbcolor:-

The visual basic defined color contains the vb constant before the normal color.

Color vbcolor

Red vbred

Green vbgreen

White vbwhite

Black vbblack

Yellow vbyellow

Blue vbblue

Brown vbbrown

Qbcolor:-

There are qbasic color of the qbasic color that are accepted by visual basic.The qbasic color contains the numeric value and displays the color.

Qbcolor functions:-

Qbcolor(number)

The color argument has these settings:

Number

Color

Number

Color

0

Black

8

Gray

1

Blue

9

Light Blue

2

Green

10

Light Green

3

Cyan

11

Light Cyan

4

Red

12

Light Red

5

Magenta

13

Light Magenta

6

Yellow

14

Light Yellow

7

White

15

Bright White

Rgb color function:-

It also returns the color.It contains the three colors Red,Green and Blue and creates the others color from these three colors.It also contains the numeric values.

Syntax:-

RGB(red as integer, green as integer, blue as integer)

Colors numbers value:-

Color

Red Value

Green Value

Blue Value

Black

0

0

0

Blue

0

0

255

Green

0

255

0

Cyan

0

255

255

Red

255

0

0

Magenta

255

0

255

Yellow

255

255

0

White

255

255

255

Color using syntax:-

control.forecolor/backcolor=color expression

Example:-

Text1.forecolor=vbred

labwork:-

a. Create the program that finds out the interest.

b. Make a program of sales invoice with subtracting discount and adding vat.

Set focus methods:-

This method of the control focuses the cursor in the particular controls.

Syntax:-

Control.setfocus

Example:-

Private Sub txtdiv_LostFocus()

txteng.SetFocus

End Sub

Timer event:-

Timer event automates the actions on its event. We have to know that the time is always constant if its interval is not increased so that running time means increasing interval.

The important two matters to work with the timer:-

1. Running timer interval by any event.

2. Running the functions within the timer event.

Timerinterval=1000 stands for 1 second.

Project:-

Make a program that displays the time automatically.[Digital watch]

Solution:-

Project name:-Digital watch.

To do :-Running time automatically.

Output:-

a. Running timer interval by Form load event.

b. write "Time" function in the timer event.

Design:-

Project:-

a. Create the digital watch where should be start and stop button to operate the watch.

b. Create mark sheet show blinking red in the fail and blinking green in the pass condition.

Combo and List box:-

Using combo and list box we can add, display and remove the data.

There are many methods to work within the combo and list box. Combo and list box contain the similar methods.

Important:-

Before writing code we have to set the "Value list" in the combo or list box.

The process of setting value list:-

a. Select the combo or list box.

b. Click on the data tab in the property box.

c. Click on Row source type.

d. Select the Value list from the combo box.

Methods:-

We can add and manipulate data into combo or list box using the following methods:-

1. Add item

2. Listindex

3. Removeitem

4. Listcount

5. Itemdata

1. additem:-

It is used to add the data in combo box or list box.

Syntax:-

Combo.additem"itemname", [indexoptional]

Example:-

2. LISTINDEX:-

It is used to find out the index value of the item in combo box or list box.

Syntax:-

Combo.listindex

Example:-

3. ITEMDATA:-

It is used to find out the item added in the combo box but item is found out on the basis of index value.

Syntax:-

Combo.itemdata (index as integer)

4. listcount:-

It is used to count the list in the combo box.

Syntax:-

Combo.listcount

Example:-

5. Remove item:-

It is used to remove the item from the combo box.

Syntax:-

Combo.removeitem(listindex)

List box:-

It is used to display many data at once. It has same methods to work with list box like in combo box.

Adding data:-

List.additem "string",index

List index:-

List.listindex

List count:-

List.listcount

Remove Item :-

List.removeitem(list index)

Item data:-

List.itemdata(list index)

Looping construct:-

Looping is the set of actions that do the functions repeatedly until the given condition is true and it terminates when the given condition is satisfied.

There are following types of looping construct:-

1. For —-next

2. while—-wend

3. Do—-loop

1.For —-next:-

This is the most usage loop used to repeat the actions until the given condition is satisfied.

It contains initial and final value with the control variable then end with next.

Syntax:-

For [control variable]=[initial value] to [final value]

[Output and calculation statement]

next

example:-

Sub gettables()

For i = 1 To 10

Debug.Print i

Next

End Sub

Step :-

When we use step it displays the data stepwise.

Syntax:-

Step [number]

Example:-

‘using steps to find even

Sub findeven()

For i = 0 To 10 Step 2

Debug.Print i

Next

End Sub

Sub multiplication_table()

For i = 1 To 10

a = "2" & "x" & i & "="

b = i * 2

Debug.Print a & b

Next

End Sub

While —-wend:-

This loop also returns the value repeatedly on the given condition until the condition is satisfied.

But this loop should be increased or decreased then only can work.

Syntax:-

Assignment

While [condition]

[increment /decrement statement]

[output statement]

Wend

Sub nn()

a = 0

While a <= 10

a = a + 1

Debug.Print a

Wend

End Sub

Do —–loop:-

This also returns the value repeatedly.

There are two do –loop

a. Do while—–loop

b. Do until—-loop

Do while—–loop

We use as following syntax :-

Do while <condition>

<increment/decrement>

<output statement>

Loop

Ex:-

Sub dowhileex()

a = 1

Do While a <= 10

a = a + 1

Debug.Print a

Loop

End Sub

Do—-until:-

Assignment

Do until <condition>

<increment/decrement>

<Output statement>

Loop

Ex:

Sub untlex()

a = 1

Do Until a = 10

a = a + 1

Debug.Print a

Loop

End Sub

Related posts:

How to Make Your Laptop Computer More Secure
iOS THE OS Killer Features OS Rater and iOS other Stars
code.org America learn their children programming
Obtain the most prominent WordPress Plugin offered today, you'll locate both free and exceptional plugins listed here. We have actually examined the entire web, reviewed hundreds of advised Wordpress plugins and picked the very best.
Discover business of technology the current innovation headlines, consisting of new item releases, sales figures and technician industry efficiency information. Read guides on brand-new gizmos and prototypes for future modern technology.
wordpress seo you need to and ought to not be doing on your Websites to make them rank greater in search engines. In a regularly transforming Search Engine Optimization garden, it is important to remain up-to-date about the changing practices and techniques of optimization.
Here is a list of software control multiple wordpress in a main location. There are WordPress dashboards, and also multisite tools to manage domains, motifs, projects, and much more. consists of one-click accessibility, monitoring, data backup, implementation, posting, and protection functions. Evaluation which of your websites have themes and plugins that need attention. Along with one click, update every one of your plugins, motifs or core WordPress software application.


Hi, My Name is Sanjan Bikram. I am a Visual Interface Designer focusing on Web Applications design, WordPress/blogger development… I am also the founder and Chief-editor of XploringMinds.Com

Share This Post

Recent Articles

One Response to “Front end form programming in visual basic”

Leave a Reply

What is 10 + 13 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)
XploringMinds is on Wordpress CMS · Designed by BloggingTalks