Friday, July 24, 2009

Day (11) Eleven Picture Box

Picture box is basically used to show pictures. it has a property named Picture where you can select the picture you want to show at design time and also can assign a picture at runtime by calling loadpicture method.

Tuesday, June 16, 2009

Visual Basic Day Ten (10) Frame

Frame is the control used for splitting your form into groups and specially grouping your Option Buttons.

Suppose you have the form in which you need to have options for Selection of Gender ( Male or Female) and another option Marital Status (Married of Single), Another Option Educated or Uneducated so if you draw six option buttons like one for each Male, Female, Married, Single, Educated, Uneducated then you can only make one selection in all of these six options but we need to make one selection in Each group i.e One from Male/Female one from Married/Single and one from Educated/Uneducated so for this reason we can use Frame.

frame is just like the form i.e a container of objects.
Drag a frame. by default its name will be frame1. frame has many common properties with other objects which are used frequently i.e Caption, Border Style, Back Color, Enabled etc.

Enabled if true then you can click on the objects on that frame but if False then you can't click on that frame.
but keep in mind one thing that when you are placing the objects on the frame then you must drag directly onto that frame or if that object is already been placed on the form then cut it from form and paste it onto frame.
in case of grouping option buttons, all option buttons on a single frame will be considered as one separate group.

Monday, June 15, 2009

VB Day Nine (9) Microsoft Common Dialog Control

MS Common Dialog control is used to enable your software to browse your system for paths.
it has many methods which are very much useful i.e to save file just call its method showsave or to open a file just call its showopen method and it will give you the small window where you can save and open a file respectively.

lets do it practically.
take a Microsoft Rich TextBox Control 6.0 and rename it as TxtExample
also make its multi line=true
and Scroll Bars= 3-Both

now take the microsoft common dialog control and rename it as CDC.

take two command buttons
rename first as CmdOpen and make its caption =Open
rename second as CmdSave and make its caption =Save

now goto click event of CmdOpen and code as


CDC.Filter = "Text files *.Txt Word Documents *.Doc All Files *.*"
CDC.ShowOpen
TxtExample.LoadFile CDC.FileName


Now goto click event of CmdSave and Code as below

CDC.Filter = "Text files *.Txt Word Documents *.Doc All Files *.*"
CDC.ShowSave
TxtExample.SaveFile CDC.FileName


so thats about how to save and load text files into rich text box

Now we want to show font formatting window (by calling ShowFont method of CDC).
for this purpose first goto Properties of CDC
and make the Flags=1

and Take a Command Button rename it as CmdFont and make its Caption=Font
on click event of CmdFont do the following code


CDC.ShowFont
TxtExample.SelBold = CDC.FontBold
TxtExample.SelItalic = CDC.FontItalic
TxtExample.SelUnderline = CDC.FontUnderline
TxtExample.SelFontName = CDC.FontName
TxtExample.SelFontSize = CDC.FontSize
TxtExample.SelStrikeThru = CDC.FontStrikethru



Now take another Command Button and rename it as CmdFontColor and make its caption=FontColor
goto click event of this button and paste the following code

CDC.ShowColor

TxtExample.SelColor = CDC.Color

and thats it. i think this will be enough for you people right now and if need more help the let me know about.

Friday, June 12, 2009

Day Eight Part -2 ( Line )

Line is another form of shape but with a few less properties.
drag a line on the form. its default name will be line1.

border color : this property is used to change the color of the line

border style: this property is used to change
Publish Post
the style i.e solid line, Dash, Dot, Dash-Dot, Dash-Dot-Dot, Inside Solid .

Border Width: this property is used to change the width of the Line. it takes a numeric value.
X1, X2, Y1, Y2 : these are the endpoints coordinates of the line, ie X1,Y1 shows the starting point of the line and X2,Y2 shows ending point of the line so you can give values to set the length of line and also the direction.

Visual Basic Day Eight (8) Shape

Shapes are used for different purposes.
for example i want to show the title of my Form inside a rounded shape or circle or underline it etc then we must use shapes.

drag a shape on form, it will be named as shape1.
another property which can be of your interest is fill style, by default it is set to transparent but you can change it to vertical lines, horizontal lines, upward diagonal, downward diagonal , solid etc.

border color, border style and a few more properties are to set the colors.
backcolor is used to change the back ground color of the shape.

Monday, June 8, 2009

VB Day Seven (7) Check Box

Check box is another very good item that is used for multiple selection.

For Example you have filling a form and need to fill that which courses you have done so far then there may be a person who haven't done any course or may be multiple courses those are given in the list then he must select more than one options.

so you can make more than one selections from a list of Check Boxes. when you click once it becomes checked and when you click it again, it becomes unchecked.



lets start it practically



Drag three Check Boxes a label and a command button

the default name of check box will be checkbox1, checkbox2 etc so rename them with Chk1 Chk2 and Chk3



also rename the label as lblResult
now i want to show that which checkboxes you have selected

goto click event of Command button and do the code as


if chk1.value=True and Chk2.Value=True and Chk3.Value=True then
LblResult.Caption="You have Checked 1,2 and 3"

elseif Chk1.Value=True and Chk2.Value=True and Chk3.Value=False then
LblResult.Caption="You have Checked 1 nad 2"

elseif Chk1.Value=True and Chk2.Value=False and Chk3.Value=True then
LblResult.Caption="You have Checked 1 nad 3"

elseif Chk1.Value=True and Chk2.Value=False and Chk3.Value=False then
LblResult.Caption="You have Checked 1"

elseif Chk1.Value=False and Chk2.Value=False and Chk3.Value=True then
LblResult.Caption="You have Checked 3"

elseif Chk1.Value=False and Chk2.Value=True and Chk3.Value=False then
LblResult.Caption="You have Checked 2"

elseif Chk1.Value=False and Chk2.Value=True and Chk3.Value=True then
LblResult.Caption="You have Checked 2 and 3"

End if


this was just to show you that you can make multiple selection.

Thursday, May 28, 2009

VB-Day Six (6) Option Button

in most of the softwares when you are given a few options and you are supposed to select at most one of these options then Option button is the best option to use. for example your country of birth. if you are given hundereds of country names and said that please select your country of birth then it will be only one you can select so option buttons form a group and from that group you can select only one option.

another example of the use of option button is selection of Gender. either Male or Female

its default name is option1, option2 and so on.

another property is Caption that is used to display what text you want to associate with it. you can have more than one groups by using Frame Object i.e on one form all option buttons will be treated as of one group so if you need some more groups then use Frame and drag option buttons on frame. each frame is a seperate group.

and to use it in code just use it as
suppose i have two option buttons named OpMale and OpFemale and i want to check whether the user selected Male of Female. i have another command button and a Label Named Lbl1

on click event of command button

'----------------------------------------------------
Private sub Command1_Click()

if OpMale.Value=True then
Lbl1.Caption="You have selected Male"
elseif OpFemale.Value=True then
Lbl1.Caption="You have selected Female"
end if

End Sub
'--------------------------------------------------

similary you can check which option button is selected. also the above functionality can be attained by coding directly on

VB-Day Five (5) Combo Box

Combo Box is another Input Item. Basically Combo box is the combination of Text Box and List Box i.e it gives you the functionality of Typing into it and also can make selection from it. it is more flexiable. the background of Combo box is also the same as of List box and also the method of adding values to it is identical as of List box. the only difference in Combo Box and List Box is that from List Box you are only given the option of Selection and can't type into it but here in Combo Box you have both the options i.e can make the selection as well as can type into it your own at run time.

same procedures can be applied to combo box too as of list box. i.e Static list and Dynamic List

Static List: in this list you just use its list property and add values at design time. one thing more that when you are adding values to list property, pressing just enter will lead you loose your focus from list property so make sure that you press Ctrl+Enter to remain in the List property and to move to next line to enter new value.

Dynamic List: ITs the same as of ListBox, you can generate it through code at runtime either from a database or from other source. the code is also the same for example i have a combo box named Combo1 and want to add some values to it at runtime then

Combo1.AddItem("First Value")
Combo1.AddItem("Second Value")
and so on

also if you want to populate it from a database then
suppose my recordset is rs ( we will cover it with database in detail later). the field name i want to display in combo box is SchoolName then

'-------------------------------------------
rs.MoveFirst
Combo1.Clear

Do While rs.EOF=False

Combo1.AddItem(rs!SchoolName)
rs.MoveNext

Loop
'---------------------------------------------
this is a simple way to show values of a table in combo box
for any queries please feel free to contact us.

Wednesday, May 27, 2009

VB-Day Four (4) List Box

Now List Box is another input item but here you can only make a selection from a pre-defined list. to use it just drag a list item from the standard tool box . its default name is List1.
to generate its list we have different methods i.e static list, dynamic list

static list: it is a predifined list of items that is feeded in the list property of the list box at design time.

Dynamic List: In this case the list is generated at runtime either from Database or from somewhere else. this is the best option for generating list.

simple example of list box is that we often select font size from List Box or font style etc.

suppose i have a listbox named List1 and i want to add some items to it at runtime through code then follow the steps below

List1.AddItem("First Value")
List1.AddItem("Second Value")
.
.
.

similarly if i have values in a table in database and want to show them all in a List box then

suppose i have rs as Recordset (we will cover it in full details later on) and the field name in the table is ValuesforList then
'-------------------------------------------
List1.Clear
rs.MoveFirst

Do while rs.EOF=False

List1.AddItem(rs!ValuesforList)
rs.MoveNext

Loop

'-------------------------------------------
This code will first clear previous values from List1 and then navigate through all the records of the recordset and will add the field's ValuesforList values to the List1.

when we use listbox in our project then it will become more clear. for any questions do contact us.

VB-Day Three (3) Text Box

Day 3 is for Textbox. Text Box is the Second most used object. its an Input object i.e we use it to accept input from the enduser and make decisions on that input and produce respective output.

A simple example will be to develop a small program that will accept two numeric values and add them and show the result. so for this purpose we will take Two TextBoxes , Three Lables and a Command Button.

Rename the Textboxes as TxtFirst and TxtSecond
Rename Lables as Lbl1, Lbl2 ,LblResult
change the captions of lables as First Number, Second Number, Result respectively.

Rename Command Button as CmdResult
Change its Caption To Add

Now goto Click Event of CmdResult and do the code as

Private sub CmdResult_Click()

LblResult.Caption="Result is = " & Val(TxtFirst.Text) + Val(TxtSecond.Text)

End Sub

Now Run the Program, Enter First number in first Textbox and second in the second textbox then click the Add Button, it will show you the Result.

----------------------------------------------------------------------------------------------
usually textboxes are used to get strings. i.e if you enter numeric values too in textboxes but they are considered string. if we remove the Val() function from the above code then it will consider the numbers as strings and will never add them but instead it will concate them so in that case the result of 2+3 will be 23 not 5
because + sign is the concatenation operator for Strings and by default everything in textbox is considered as string. you have to use Val() function to tell vb that you are using numeric properties not string properties.

another Concatenation operator is & sign in Vb, but it is for all types of data i.e 1 & 2 will be 12
or val(1) & val(2) will be 12 so it means that irrespective of datatypes it is a concatenation operator.

we opten use locked property of textbox to lock it for input or enabled property to just show something that cannot be changed by anybody directly by typing.

VB Day Two (2) Command Button

In this lesson we will disscuss Command Button.

This is the normal button you usually use in every application now a days.
its Default Name is Command1, Command2 and so on...
We mostly use its Click event to code and its Enabled property to make it active or passive according to the situation.

when you drag the Command Button object on the form, its Name is Command1 and Also the caption. caption is the text that appears to the user at runtime and name is of programmer's interest.

Suppose i want to take a command button and want that when i click it, the form background color changes automatically and Randomly
so take a command button and rename it with

CmdFirst

now goto click event of this button and code like below

Private sub CmdFirst_Click()

Form1.BackColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)

End Sub

where Form1 is the Name of the form that contains this Command Button. now if you run this application and click on the button, each time it will make a color randomly from the 1-255 for each red, green and blue colors and will make a new color of this combination.

similary if i have two buttons suppose CmbFirst and CmbSecond and want that when i click CmbFirst then CmbSecond can't be clicked and when click CmbFirst again then CmbSecond can be clicked then we will change the enabled property of CmbSecond on Click Event of CmbFirst as

Private Sub CmbFirst_Click()

CmbSecond.Enabled=not CmbSecond.Enabled

End Sub

here we used "Not" operator that works as if it is Enabled then make it disable and if it is disabled then make it enable.

--------------------------------------------------------------------------------------------
Also we can change the Caption at runtime by firing of some event of another object. suppose when i click the First Button then it makes the second button Disabled and changes caption of itself to "Click To Enable Second Button"

and when we click it to Enabled the Second button then it enables the Second button and changes its caption to "click me to disable second button "


Goto Click Event of CmdFirst and code as

Private sub CmdFirst_Click()

CmdSecond.Enabled=Not CmdSecond.Enabled

if CmdSecond.Enabled=True then
CmdFirst.Caption="Click Me to Disable Second Button"
Else
CmdFirst.Caption="Click Me to Enable Second Button"

End if

End sub

here we have used if statement which we will discuss in details a bit later. for now just use it as it is. it actually checks if first condition is true then it will follow the instruction just after that and if it becomes false then it comes to the else part and executes that part.

similary we will use command button in our examples very much and will change its many properties as needed in different situations. Changing the mouse pointer when our mouse comes over it , changing picture on its top but changing background picutre or backcolor of command button in vb, you need to change the Style property to Graphical instead of Standard.
if somebody want more things to do with button, directly contact us.
we will interact with button most of the times and our many problems will get solved accordingly as we proceed further.

Tuesday, May 26, 2009

Vb-Day One (1)

First of all we will list out all the items that we need to cover before starting this Database Project.

1. Form Object
2. Command Button
3. TextBox
4. Combo Box
5. List Box
6. Option Button
7. Check Box
8. Shapes
9. Labels
10. Common Dialog Control 6.0
11. Frame
12. Picture Box
13. Date Time Picker
14. MsFlex Grid
15. DataGrid
16. Creating Tool Bar
17. Creating Menu
18. Database Interaction (Connectivity, Retrieval, Insertion, Updation, Deletion)
19. ADODC
20. MDI (Multiple Document Interface) Form (Used when you have more than one forms)
21. Module
22. Crystal Report
23. Making Executable
24. Packaging and Deployment (How to make Setup File)

So we are going to cover each of these objects one by one with examples and then will start Database Project in which we will use all of these combinely.

1. Form: Form is the Container of objects i.e we use it to design our front end. we place different objects on one form.
in one project we can have multiple forms. we can navigate between them by calling the respective form like if Form1 and Form2 are two forms then to call form1 just code like

Load Form1
Form1.Show
Form1.Setfocus

Each and every object has its own Methods and Properties. we just call their methods and change values to their properties and get our task done. so if you goto code window in vb you will get two combo boxes at the top. the left one is populated with the object names and when you select an object from this combo, the right one is populated with the events related to that specific object so you do code on specific events. for example if i want to change the back color (property) of the form when i click it then i must first goto code window and select form object from the left combo. then from right combo i will select click
this will give the the environment like below

Private sub Form_Click()


End sub

so all code that i need to fire on click event should be typed inside these two lines. right now i want to change the form color so i do as

Private sub Form_Click()

Me.Backcolor=vbgreen

End sub

here Me refers to the current form. you can also put the object name instead like

Form1.Backcolor=vbgreen

form has many events and properties which we will cover in different small examples. for now as it is the starting point so just keep in mind that we use form as the Container of objects. Its the main object in our Fornt-End designing.

Visual Basic Tutorial (Day by Day)

Dear all!
here is the Visual Basic Tutorial (Day by Day).
by following this tutorial you will be enable to do a Database Project by yourself.

Visual Basic Programming....

Welcome to the world of Visual Basic Programming....

Teach the world how to code in Visual Basic using this platform.....

What is Programming?

Share your ideas here about programming in terms of Computer.........

Thursday, May 21, 2009

What is the future of IT Professionals?

Every field is expanding by research and the field of IT is very much fast in this regard. can anybody guess what will be the position of IT Professionals after 5 years?

Wednesday, May 20, 2009

What is the difference between Computer Science and IT?

can anybody give me the difference between Computer Science and Information Technology?

Welcome to Wha8izIT....

We welcome IT Professionals to our blog..........