0% found this document useful (0 votes)
17 views

VB Answers 1

Uploaded by

Nitesh Bhatt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

VB Answers 1

Uploaded by

Nitesh Bhatt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

1.

Procedural Oriented Programming


Object-Oriented Programming

In procedural programming, the program is In object-oriented programming, the


divided into small parts called functions. program is divided into small parts called
objects.

Procedural programming follows a Object-oriented programming follows a


top-down approach. bottom-up approach.

Adding new data and functions is not easy. Adding new data and function is easy.

Procedural programming does not have any Object-oriented programming provides


proper way of hiding data so it is less data hiding so it is more secure.
secure.

In procedural programming, overloading is Overloading is possible in objectoriented


not possible. programming.

In procedural programming, there is no In object-oriented programming, the


concept of data hiding and inheritance. concept of data hiding and inheritance is
used.

Examples: C, FORTRAN, Pascal, Examples: C++, Java, Python, C#, etc.


Basic, etc.
2. Hiding and showing forms is a user interface technique used to control the visibility of
input forms based on user actions or conditions. This approach enhances the user
experience by making interactions more intuitive and focused. Here’s a more detailed
explanation:

Hiding Forms
• Purpose: Forms may be hidden to simplify the interface or to prevent user
confusion. For instance, if a user completes a step, the corresponding form
can be hidden to show the next step.
• Examples: o A login form that disappears after a user successfully logs
in.
 A detailed input form that is hidden until a user selects a specific option
(e.g., "Add More Details").

Syntax = Private Sub form1_Click()

MyForm2.Hide

End Sub

Showing Forms
• Purpose: Forms are displayed to allow users to enter information or make selections.
This can be based on user actions, such as clicking a button or selecting an option from
a dropdown.
• Examples: o A feedback form that appears after a user completes a transaction. o A
settings form that becomes visible when a user clicks on a "Settings" button.

Syntax = Private Sub form1_Click()

MyForm1.Show

End Sub

3.

One Dimensional Array:


• It is a list of the variable of similar data types.
• It allows random access and all the elements can be accessed with the help of
their index.
• The size of the array is fixed.
• For a dynamically sized array, vector can be used in C++.
• Representation of 1D array:
Two Dimensional Array:
• It is a list of lists of the variable of the same data type.
• It also allows random access and all the elements can be accessed with the help
of their index.
• It can also be seen as a collection of 1D arrays. It is also known as the Matrix.
• Its dimension can be increased from 2 to 3 and 4 so on.
• They all are referred to as a multi-dimension array.
• The most common multidimensional array is a 2D array.
• Representation of 2 D array:

4. The Immediate Window and the Go To Window are features commonly found in
development environments, especially in applications like Microsoft Visual Studio or
VBA (Visual Basic for Applications). Here's an overview of each:

Immediate Window
Purpose:

The Immediate Window is a tool used primarily for debugging and executing commands or
code snippets on-the-fly within a programming environment.

Key Features:

• Execute Commands: You can run expressions, commands, or functions directly without
needing to compile or run the entire program.
• Evaluate Expressions: Allows you to check the value of variables or expressions at runtime.
• Debugging: Useful for debugging by letting you inspect variable values, change them, or
call functions while the program is paused.
• Print Output: You can output text and variable values using commands like Debug.Print.

Go To Window
Purpose:
The Go To Window (or Go To Definition/Go To Line) is used for navigation within the
code, helping developers quickly jump to specific sections of the codebase.

Key Features:

• Navigate to Code Elements: Allows you to jump directly to functions, classes, or variables
in the code.
• Line Number Navigation: You can specify a line number to quickly move to that point in
the file.
• Search Functionality: Often includes search features to find specific code segments or
keywords.

5. SDI (Single Document Interface) and MDI (Multiple Document Interface) are two different ways
to manage windows in graphical user interfaces, particularly in applications that handle multiple
documents or views.

Single Document Interface (SDI)


Definition:

In an SDI application, each document is opened in its own separate window. This means
that when you open a new document, a new instance of the application window is created
for it.

Examples:

• Text editors (like Notepad).


• Image editing software (like Adobe Photoshop when opening images in separate

windows).

Multiple Document Interface (MDI)

Definition:

In an MDI application, multiple documents are contained within a single main application
window. Each document appears as a child window within the main window.

Examples:

• Microsoft Excel, where multiple spreadsheets can be opened within a single


window.
• Older versions of Microsoft Word (before it moved to a tabbed interface).
BASIS OF
MDI SDI
COMPARISON

MDI is a type of graphic user interface which SDI is a Graphic User Interface which
Description is able to show more than a single document is able to show one document at a
at a time on the screen. time on the screen.

Child windows per documents are allowed in One document per window is enforced
Limits
MDI. in SDI.

Container Control MDI is a container control. SDI is not a container control.

MDI contains multiple documents which at a SDI contains one window only at a
Operation
time appear as child window. time.

MDI supports many interfaces which means SDI supports one interface which
Interface you can handle many applications at a time means you can handle only one
according to user’s requirement. application at a time.

Switching Between For switching between documents MDI uses For switching between documents SDI
Documents special interface inside the parent window. uses Task Manager for that.

SDI grouping is possible through


Grouping In MDI grouping is implemented naturally.
special window managers.

For maximizing documents, parent


Maximizing For maximizing documents, parents window
windows are maximized through a
Documents is maximized by MDI.
special code or window manager.

Switching focus to the specific document can Switching focus to specific document
Flexibility
be easily handled by MDI. is difficult to implement in SDI.
Unit - 1
1. he VB (Visual Basic) environment refers to the integrated development environment
(IDE) used to create applications with Visual Basic, a programming language developed by
Microsoft. The VB environment provides various tools and features to help developers
design, code, and test their applications. Here’s an explanation of key components:

1. Toolbox
• Definition: The Toolbox is a panel that contains various controls and components that can
be added to forms. These controls include buttons, text boxes, labels, combo boxes, and
more.
• Usage: Developers can drag and drop these controls onto the form designer to create the
user interface of the application. Each control has its own properties and events that can be
configured.

2. Properties Window
• Definition: The Properties Window displays the properties of the currently selected object
(such as a form or a control).
• Usage: This window allows developers to modify various attributes of the selected control,
such as size, color, font, and event handlers. Changes made in the Properties Window are
reflected in real-time on the form.

3. Form Designer
• Definition: The Form Designer is a visual interface where developers can design the layout
of their application's user interface.
• Usage: Developers can add controls from the Toolbox to the form, arrange them, and set
their properties using the Properties Window. The Form Designer provides a WYSIWYG
(What You See Is What You Get) experience, allowing developers to see how the UI will
look at runtime.

4. Form Layout Detail


• Definition: Form layout detail refers to the arrangement and organization of controls on a
form to ensure a logical and user-friendly interface.
• Considerations:
o Alignment: Controls should be aligned properly for a clean look. o
o Spacing: Adequate spacing between controls enhances readability and usability.
o Grouping: Related controls can be grouped together to make the interface intuitive.
o Accessibility: Ensuring that controls are accessible and easy to navigate is crucial
for user experience.

Unit – 2
Input Controls
1. TextBox
o Description: Allows users to enter and edit text.
o Usage: Commonly used for user input such as names, addresses, and other textual
information.
2. ComboBox
o Description: A dropdown list that allows users to select an item from a list or enter a
custom value.
o Usage: Useful for selecting from predefined options while also allowing input of
new values.
3. ListBox
o Description: Displays a list of items from which users can select one or more.
o Usage: Ideal for presenting multiple options where users can select items.
4. CheckBox
o Description: A control that allows users to make a binary choice (checked or
unchecked).
o Usage: Used for options that can be toggled, such as preferences or settings.
5. RadioButton
o Description: Allows users to select one option from a group of choices.
o Usage: Commonly used when only one selection is allowed among multiple options.
6. Slider (TrackBar)
o Description: A control that lets users select a value from a range by sliding a
handle along a bar. o Usage: Useful for selecting numerical values, such as volume
levels or brightness.

Output Controls
1. Label
o Description: Displays static text or information to the user. o
Usage: Used for titles, descriptions, or instructions without requiring
user interaction.
2. PictureBox
o Description: Displays images or graphics.
o Usage: Useful for showing icons, photos, or any visual representation.
3. ListView
o Description: A control that displays a list of items in a detailed format with columns.
o Usage: Often used to present complex data in a structured way.
4. DataGridView
o Description: A control for displaying and editing data in a tabular format. o
Usage: Commonly used to present data from databases or collections.

(b)

1. Numeric Data Types


 Byte
o Description: Stores unsigned integers from 0 to 255.
o Size: 1 byte.
 Short
o Description: Stores signed integers from -32,768 to 32,767.
o Size: 2 bytes.
 Integer
o Description: Stores signed integers from -2,147,483,648 to 2,147,483,647.
o Size: 4 bytes.
 Long
o Description: Stores signed integers from -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807.
o Size: 8 bytes.
 Single
o Description: Stores single-precision floating-point numbers.
o Size: 4 bytes.
 Double
o Description: Stores double-precision floating-point numbers.
o Size: 8 bytes.
 Decimal
o Description: Stores high-precision decimal numbers, useful for financial
calculations. o Size: 16 bytes.

2. Character and String Data Types


 Char
o Description: Represents a single Unicode character.
o Size: 2 bytes.
 String
o Description: Represents a sequence of characters (text).
o Size: Variable length (based on the number of
characters).

3. Boolean Data Type


 Boolean
o Description: Represents a value of either True or False.
o Size: 2 bytes.

4. Date and Time Data Type


 Date
o Description: Represents dates and times.
o Size: 8 bytes.
5. Object Data Type
 Object
o Description: Can store any data type, including user-defined types and
reference types. o Size: 4 bytes (reference).
6. Variant Data Type (in older VB versions)
 Variant
o Description: Can contain any type of data (used in earlier versions of VB, primarily
VB6).
o Note: Not used in VB.NET; replaced by the Object type

(C) MsgBox ( ) Function

The objective of MsgBox is to produce a pop-up message box and prompt the user
to click on a command button before he /she can continues. This format is as
follows:

Syntax = yourMsg=MsgBox(Prompt, Style Value, Title)


For example =
Sub MessageBox_vbOKOnly()

Dim OutPut As Integer


OutPut = MsgBox("Thanks for visiting Analysistabs!", vbOKOnly, "Example of vbOKOnly")

End Sub

 THE INPUTBOX( ) FUNCTION


An InputBox( ) function will display a message box where the user can enter a value or a
message in the form of text. The format is:

Syntax = InputBox(Prompt, Title, Default, Xpos, Ypos)

For example : Sub BasicInputBoxExample()

Dim inputVal As String

inputVal = InputBox("Please enter a value")

End Sub

 Print statement ()

The Print # statement can also be used to print output to a text file. This is useful
for creating reports or saving data from a macro. In order to print to a text file, you must
first open the file using the Open statement and specifying the Output mode.

Syntax : Print # statemen

For example = Dim x As Integer, y As Integer

x = 10
y = 20

Print #1, "The value of x is", x, "and the value of y is", y

You might also like