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
Thursday, May 28, 2009
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.
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.
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.
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.
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.
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.
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.....
Teach the world how to code in Visual Basic using this platform.....
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?
Subscribe to:
Posts (Atom)