Subject Code and Name: BT0082 and Visual Basic
Roll No: 1408005884
1. Explain the process of extracting and drawing images using image list
control.
Answer: Extracting Individual Images
A picture property can be exposed by each list image object. This makes you to
extract the image and assign it to other control object, which can be a Picture
Box or an Image control:
Set Picture1.Picture = ImageList1.ListImage(“Cut”).Picture
Picture property of a List Image Object can be used anywhere required. The
example shows how a Picture property of a Picture Box is used:
‘Save an Image to a disk file.
Save Picture ImageList1.ListImages(“Cut”).Picture,”C:cut.bmp”
‘Display an image on the current form, zooming it by a factor
‘of 4 along the X-axis, and 8 along the Y-axis
With ImageList1
PaintPicture.ListImages(“Cut”).Picture,0,0,ScaleX(.Imagewidth,vbPixels)*4,
_ScaleY(.ImageHeight,vbPixels)
List Imageobjects also exposean Extraction method, which creates an icon out
of the image and returns it to the earlier. You can therefore use this method
whenever an icon is expected, as in this code:
Form1.MouseIcon = ImageList1.ListImages(“Pointer”).Extraction
Drawing Images
List Image objects support the Draw method, which has the following syntax:
Draw hDC, [x],[y],[Style]
Where hDC is the handle of a device context(typically the value returned by
the hDC property of a form, a PictureBox control, or the Printer object) and x
and y are the coordinates in pixel where the image should be displayed in the
target object. Style is one of the following values: 0-imlNormal(default, draw
the image without any change), 1-imlTransparent (use the Maskcolor property
to account for transparent areas), 2-imlSelected (draw the image diethered
with the system highlight color), or 3-imlFocus (as imlSelected, but create a
hatched effect to indicate that the image has the focus):
‘Show an image in the upper left corner of a PictureBox control.
ImageList1.ListImage(“Cut”).Draw Picture1.hDC,0,0
2. Explain the concept of inheritance in VB.Net.
Answer: Inheritanceis a powerful tool that saves you a lot of work if you use it
correctly. ”Correctly” means that you should not use inheritance if it is not
absolutely clear that the “is a” relationship holds:
 Class A should inherit from a class B only when it is absolutely clear that,
now and forever, you can always use an A object in place of B object
without getting yourself into a trouble.
You may see this fundamental rule in a more abstract form. This kind of
abstraction is necessary when you try to express the rule in a code oriented way:
 An instance of a child class A that inherits from a parent class B must be
usable in every piece of code that would take an instance of its parent
type as a parameter. In other words if you have a function whose
header is
Uselt(b Thing As B)
And a Thing is an instance of the child class A, then the following code
must make sense:
Uselt(a Thing)
3. Explain the concept of Exit Try statement in VB.Net with an example.
Answer: The Exit Try statement break out of the Try or Catch block and
continue at the Finally block.
Example:
Private Function GetAverage5 (items As Integer, iTotal as Integer) As Single
‘Code that might throw an exception is wrapped in a Try block.
Try
Dim sngAverage = CSng(I Total/Items)
‘This only executes if the line above generated no error.
MessageBox.Show(“Calculation successful”)
Return sngAverage
Cactch excDivideByZero As DivideByZeroException
‘You will gwt here with an DivideByzeroException in the Try block.
If items = 0Then
Return 0
Exit Try
Else
MessagezBox.Show(“Error not caused by items”)
End If
Throw excDivideByZero
MessageBox.Show(“More logic after the thrown – never executed”)
Catch excGeneric As Exception
‘You,ll get here when any exception is thrown and not caught in
‘ a previous Catch block.
MessageBox.Show (“Calculation failed – generic exception caught”)
Throw excGeneric
Finally
‘Code in the Finally block will always run, even if
‘an exception was thrown in a Catch block.
MessageBox.Show(“You always get here, with or without an error”)
End Try
End Sub
In your first Catch block, you have inserted an If block so that you can exit the
block given a certain condition. The Exit Try goes immediately to the Finally
block and completes the processing there:
If items=0 Then
Return 0
Exit Try
Else
MessagerBox.Show(“Error not caused by items”)
End If
4. Define SQL. Explain the select statement of SQL with examples.
Answer: SQL (Structured Query Language) is a language is used to access,
delete, update and create databases. This is easy and simple to learn.
To view all the data in a table, following query has to be written:
SELECT*FROM Table Name;
The language is not case sensitive. The abovestatement can also be written as:
Select*from Table Name;
The suggested protocol is to use UPPERCASE for the keywords. The above
whole line reads:
“SELECT all the records FROM the table called Table Name”
Always it is not necessary to select all the records using ”*".
If the table has two column fields first name and surname, you can specify the
query statement:
SELECT tblContacts.FirstName, tblContacts.SurName FROM tblContacts
When this query is executed, the FirstName and SurName columns will be
returned.
If you are using the free 2005 Express edition, you might see DataSet with a
wiggly line under it. This is because you need to set a reference to something
called System.Xml.dll. To do that, click Project>Add Reference from the menu
bar.
5. Describe the concept of record navigation in VB.Net.
Answer: Record Navigation:
(i) Move Back One Record at a Time
To scroll backwards through the dataset, we need to reduce the value of inc by
1. That is to go by one record we have to decrement inc by 1 from whatever
the currentvalue it has. Oncethe code is finished, run the program. A message
box should display when you click on the Previous button. This will happen
even though no records have been loaded in text boxes. This happens due to
the inc value is -1 when the form loads. When Next button is clicked, the value
gets assigned to zero.
If inc>0 Then
Inc = inc-1
Navigate Records()
ElseIf inc= -1 Then
MsgBox(“No Records Yet”)
ElseIf inc = 0 Then
MsgBox(“First Record”)
End If
Now inc is checked whether it is equal to -1 using the new if statement. If it is
not then displays a message. A message box with a message “”First Record ” is
displayed.
(ii) Moving to the Last Record in the DataSet
To navigate to the last record of the DataSet, you should know the count of
the records loaded into DataSet i.e., the MaxRows variable in the code.
If inc<>MaxRows-1 Then
` inc=MaxRows-1
NavigateRecords()
End If
Within the if statement , inc is set to MaxRows-1. Then NavigateRecords()
subroutine is executed.
(iii) Moving to the First Record in the DataSet
We have to assign a value 0 to the inc counter.
If inc<>0 Then
Inc=0
NavigateRecords()
EndIf
This code is to be added to the btnFirst.
6. Describe the concept of jagged arrays in visual basic with an example.
Answer: A consecutive group of memory locations having same name and type
is said to be an array. The elements in the array are put within name and type
is said to be an array.
An array of which each element is itself an array is called array of arrays or a
jagged array.
Having array as elements is not the same thing as a multidimensional array,
which has more than one index on a single array.
Sometimes the data structure in your application is two-dimensional but not
rectangular. For example, you might have an array of months, each element5s
of which is an array of days. Since different months have different numbers of
days, the elements do not forma rectangular two-dimensional array. In such a
case, you can use a jagged array instead of a multidimensional array.
Example:
The following example declares an array variable to hold an array of arrays
with elements of the Double Data Type. Each element of the array sales is
itself an array that represents a month. Each month array holds values for each
day in that month.
Dim sales()() As Double = New Double(11)(){}
Dim month As Integer
Dim days As Integer
For month = 0 To 11
Days = DateTime.DaysInmonth(Year(Now), month +1)
sales(month) = New Double(days-1){}
Next month
The New clause in the declaration of sales sets the array variable ro a 12-
element array, each element of which is of type Double(), an array of Double
elements. The For loop then determines how many days are in each month
this year (Year(New)),and sets the corresponding element of sales to a Double
array of the appropriate size.
The jagged array saves seven elements as compared to a two dimensional
array. When you initialize a jagged array variable, you van specify the
dimension lengths only for the top-level array.

More Related Content

DOCX
Summary_Onset (1)
PPTX
Chapter 7.1
PDF
Array and Collections in c#
DOCX
Sap pi 10 nodes
PPT
Java căn bản - Chapter3
PPTX
PDF
Bt0082 visual basic2
PPTX
1.2 matlab numerical data
Summary_Onset (1)
Chapter 7.1
Array and Collections in c#
Sap pi 10 nodes
Java căn bản - Chapter3
Bt0082 visual basic2
1.2 matlab numerical data

What's hot (16)

PPT
Chap09
PPT
Arrays Class presentation
PPTX
Array in c#
PPTX
Array in C# 3.5
PDF
Matlab for marketing people
PPT
Java: Introduction to Arrays
PPS
Advance Excel tips
DOC
08review (1)
PPTX
PPTX
Icom4015 lecture4-f17
PPTX
Array lecture
DOC
one of the rules cited in class for making e-mail more effective Experience T...
PDF
Java arrays (1)
PDF
Which of the following is not one of the rules cited in class for making e ma...
PPTX
3.3 the math object
Chap09
Arrays Class presentation
Array in c#
Array in C# 3.5
Matlab for marketing people
Java: Introduction to Arrays
Advance Excel tips
08review (1)
Icom4015 lecture4-f17
Array lecture
one of the rules cited in class for making e-mail more effective Experience T...
Java arrays (1)
Which of the following is not one of the rules cited in class for making e ma...
3.3 the math object
Ad

Similar to Visual basic bt0082 (20)

PPTX
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
PPT
VB_ERROR CONTROL_FILE HANDLING.ppt
PPTX
Sharbani bhattacharya VB Structures
DOCX
Objectives Assignment 09 Applications of Stacks COS.docx
PDF
Curve fitting
DOCX
Tutorials on Macro
PDF
LectureNotes-06-DSA
PPTX
Collections
DOCX
Itm310 problem solving #7 complete solutions correct answers key
PDF
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
DOCX
ObjectivesMore practice with recursion.Practice writing some tem.docx
PDF
PPTX
CPP homework help
DOCX
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
DOCX
The second programming assignment (HW4) is designed to help you ga.docx
DOCX
Use the following data set that compares age to average years lef.docx
PDF
Programming in matlab lesson5
PDF
Useful macros and functions for excel
PPTX
Advanced VB: Review of the basics
PPTX
Advanced VB: Review of the basics
VISUAL BASIC 6 - CONTROLS AND DECLARATIONS
VB_ERROR CONTROL_FILE HANDLING.ppt
Sharbani bhattacharya VB Structures
Objectives Assignment 09 Applications of Stacks COS.docx
Curve fitting
Tutorials on Macro
LectureNotes-06-DSA
Collections
Itm310 problem solving #7 complete solutions correct answers key
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
ObjectivesMore practice with recursion.Practice writing some tem.docx
CPP homework help
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
The second programming assignment (HW4) is designed to help you ga.docx
Use the following data set that compares age to average years lef.docx
Programming in matlab lesson5
Useful macros and functions for excel
Advanced VB: Review of the basics
Advanced VB: Review of the basics
Ad

Recently uploaded (20)

PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PPTX
20th Century Theater, Methods, History.pptx
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
Computer Architecture Input Output Memory.pptx
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
My India Quiz Book_20210205121199924.pdf
PPTX
Virtual and Augmented Reality in Current Scenario
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
Weekly quiz Compilation Jan -July 25.pdf
Share_Module_2_Power_conflict_and_negotiation.pptx
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
AI-driven educational solutions for real-life interventions in the Philippine...
20th Century Theater, Methods, History.pptx
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
What if we spent less time fighting change, and more time building what’s rig...
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Computer Architecture Input Output Memory.pptx
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
My India Quiz Book_20210205121199924.pdf
Virtual and Augmented Reality in Current Scenario
B.Sc. DS Unit 2 Software Engineering.pptx
Chinmaya Tiranga quiz Grand Finale.pdf

Visual basic bt0082

  • 1. Subject Code and Name: BT0082 and Visual Basic Roll No: 1408005884 1. Explain the process of extracting and drawing images using image list control. Answer: Extracting Individual Images A picture property can be exposed by each list image object. This makes you to extract the image and assign it to other control object, which can be a Picture Box or an Image control: Set Picture1.Picture = ImageList1.ListImage(“Cut”).Picture Picture property of a List Image Object can be used anywhere required. The example shows how a Picture property of a Picture Box is used: ‘Save an Image to a disk file. Save Picture ImageList1.ListImages(“Cut”).Picture,”C:cut.bmp” ‘Display an image on the current form, zooming it by a factor ‘of 4 along the X-axis, and 8 along the Y-axis With ImageList1 PaintPicture.ListImages(“Cut”).Picture,0,0,ScaleX(.Imagewidth,vbPixels)*4, _ScaleY(.ImageHeight,vbPixels) List Imageobjects also exposean Extraction method, which creates an icon out of the image and returns it to the earlier. You can therefore use this method whenever an icon is expected, as in this code: Form1.MouseIcon = ImageList1.ListImages(“Pointer”).Extraction
  • 2. Drawing Images List Image objects support the Draw method, which has the following syntax: Draw hDC, [x],[y],[Style] Where hDC is the handle of a device context(typically the value returned by the hDC property of a form, a PictureBox control, or the Printer object) and x and y are the coordinates in pixel where the image should be displayed in the target object. Style is one of the following values: 0-imlNormal(default, draw the image without any change), 1-imlTransparent (use the Maskcolor property to account for transparent areas), 2-imlSelected (draw the image diethered with the system highlight color), or 3-imlFocus (as imlSelected, but create a hatched effect to indicate that the image has the focus): ‘Show an image in the upper left corner of a PictureBox control. ImageList1.ListImage(“Cut”).Draw Picture1.hDC,0,0 2. Explain the concept of inheritance in VB.Net. Answer: Inheritanceis a powerful tool that saves you a lot of work if you use it correctly. ”Correctly” means that you should not use inheritance if it is not absolutely clear that the “is a” relationship holds:  Class A should inherit from a class B only when it is absolutely clear that, now and forever, you can always use an A object in place of B object without getting yourself into a trouble. You may see this fundamental rule in a more abstract form. This kind of abstraction is necessary when you try to express the rule in a code oriented way:  An instance of a child class A that inherits from a parent class B must be usable in every piece of code that would take an instance of its parent type as a parameter. In other words if you have a function whose header is Uselt(b Thing As B)
  • 3. And a Thing is an instance of the child class A, then the following code must make sense: Uselt(a Thing) 3. Explain the concept of Exit Try statement in VB.Net with an example. Answer: The Exit Try statement break out of the Try or Catch block and continue at the Finally block. Example: Private Function GetAverage5 (items As Integer, iTotal as Integer) As Single ‘Code that might throw an exception is wrapped in a Try block. Try Dim sngAverage = CSng(I Total/Items) ‘This only executes if the line above generated no error. MessageBox.Show(“Calculation successful”) Return sngAverage Cactch excDivideByZero As DivideByZeroException ‘You will gwt here with an DivideByzeroException in the Try block. If items = 0Then Return 0 Exit Try Else MessagezBox.Show(“Error not caused by items”) End If
  • 4. Throw excDivideByZero MessageBox.Show(“More logic after the thrown – never executed”) Catch excGeneric As Exception ‘You,ll get here when any exception is thrown and not caught in ‘ a previous Catch block. MessageBox.Show (“Calculation failed – generic exception caught”) Throw excGeneric Finally ‘Code in the Finally block will always run, even if ‘an exception was thrown in a Catch block. MessageBox.Show(“You always get here, with or without an error”) End Try End Sub In your first Catch block, you have inserted an If block so that you can exit the block given a certain condition. The Exit Try goes immediately to the Finally block and completes the processing there: If items=0 Then Return 0 Exit Try Else MessagerBox.Show(“Error not caused by items”) End If
  • 5. 4. Define SQL. Explain the select statement of SQL with examples. Answer: SQL (Structured Query Language) is a language is used to access, delete, update and create databases. This is easy and simple to learn. To view all the data in a table, following query has to be written: SELECT*FROM Table Name; The language is not case sensitive. The abovestatement can also be written as: Select*from Table Name; The suggested protocol is to use UPPERCASE for the keywords. The above whole line reads: “SELECT all the records FROM the table called Table Name” Always it is not necessary to select all the records using ”*". If the table has two column fields first name and surname, you can specify the query statement: SELECT tblContacts.FirstName, tblContacts.SurName FROM tblContacts When this query is executed, the FirstName and SurName columns will be returned. If you are using the free 2005 Express edition, you might see DataSet with a wiggly line under it. This is because you need to set a reference to something called System.Xml.dll. To do that, click Project>Add Reference from the menu bar.
  • 6. 5. Describe the concept of record navigation in VB.Net. Answer: Record Navigation: (i) Move Back One Record at a Time To scroll backwards through the dataset, we need to reduce the value of inc by 1. That is to go by one record we have to decrement inc by 1 from whatever the currentvalue it has. Oncethe code is finished, run the program. A message box should display when you click on the Previous button. This will happen even though no records have been loaded in text boxes. This happens due to the inc value is -1 when the form loads. When Next button is clicked, the value gets assigned to zero. If inc>0 Then Inc = inc-1 Navigate Records() ElseIf inc= -1 Then MsgBox(“No Records Yet”) ElseIf inc = 0 Then MsgBox(“First Record”) End If Now inc is checked whether it is equal to -1 using the new if statement. If it is not then displays a message. A message box with a message “”First Record ” is displayed. (ii) Moving to the Last Record in the DataSet To navigate to the last record of the DataSet, you should know the count of the records loaded into DataSet i.e., the MaxRows variable in the code. If inc<>MaxRows-1 Then
  • 7. ` inc=MaxRows-1 NavigateRecords() End If Within the if statement , inc is set to MaxRows-1. Then NavigateRecords() subroutine is executed. (iii) Moving to the First Record in the DataSet We have to assign a value 0 to the inc counter. If inc<>0 Then Inc=0 NavigateRecords() EndIf This code is to be added to the btnFirst. 6. Describe the concept of jagged arrays in visual basic with an example. Answer: A consecutive group of memory locations having same name and type is said to be an array. The elements in the array are put within name and type is said to be an array. An array of which each element is itself an array is called array of arrays or a jagged array. Having array as elements is not the same thing as a multidimensional array, which has more than one index on a single array. Sometimes the data structure in your application is two-dimensional but not rectangular. For example, you might have an array of months, each element5s of which is an array of days. Since different months have different numbers of days, the elements do not forma rectangular two-dimensional array. In such a case, you can use a jagged array instead of a multidimensional array.
  • 8. Example: The following example declares an array variable to hold an array of arrays with elements of the Double Data Type. Each element of the array sales is itself an array that represents a month. Each month array holds values for each day in that month. Dim sales()() As Double = New Double(11)(){} Dim month As Integer Dim days As Integer For month = 0 To 11 Days = DateTime.DaysInmonth(Year(Now), month +1) sales(month) = New Double(days-1){} Next month The New clause in the declaration of sales sets the array variable ro a 12- element array, each element of which is of type Double(), an array of Double elements. The For loop then determines how many days are in each month this year (Year(New)),and sets the corresponding element of sales to a Double array of the appropriate size. The jagged array saves seven elements as compared to a two dimensional array. When you initialize a jagged array variable, you van specify the dimension lengths only for the top-level array.