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.
Tuesday, June 16, 2009
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.
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 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.
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
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.
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.
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.
Subscribe to:
Posts (Atom)