[go: up one dir, main page]

0% found this document useful (0 votes)
11 views49 pages

VB Practical

The document is a practical file for a Visual Programming course at D.A.V. Centenary College, detailing various projects and topics related to Visual Basic 6.0. It covers definitions, user interface components, control properties, database connectivity types, and methods of the Recordset object. The content is structured with an index and includes descriptions of controls like TextBox, CommandButton, and others, along with their properties, events, and methods.

Uploaded by

llrestiorana
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)
11 views49 pages

VB Practical

The document is a practical file for a Visual Programming course at D.A.V. Centenary College, detailing various projects and topics related to Visual Basic 6.0. It covers definitions, user interface components, control properties, database connectivity types, and methods of the Recordset object. The content is structured with an index and includes descriptions of controls like TextBox, CommandButton, and others, along with their properties, events, and methods.

Uploaded by

llrestiorana
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/ 49

D.A.V.

CENTENARY
COLLEGE,
FARIDABAD
PRACTICAL FILE

Maharshi Dayanand
University,
Rohtak

SUBJECT CODE- 303

VISUAL PROGRAMMING

Department of
Bachelor in Computer Application
Submitted By: Submitted To:
TUSHAR KUMAR MR. DINESH KUMAR
1221783011094 ASSISTANT PROFESSOR

2024/2025
Index

Page No. Remark /


S.No. Projects Signature

1. Define Visual Programming Language, how it is different


from other Traditional Programming Language

2. Introduction of User Interface / Platform provided by VB6.0


with its different Components and Features

Define TextBox , CommandButton, OptionButton, CheckBox,


3. ListBox and ComboBox with their important properties,
events and methods.

4. Write down different types of Database Connectivity’s and


five methods of Recordset

5. Design a Calculator dialog window

6. Design a Font dialog window

7. Design a Color Palette dialog window

8. Design a Login Form dialog window

9. Design a Registration Form dialog window

10. Design a Table Create (Using Looping) dialog window

11. Design a Traffic Light dialog window

12. Design a Marquee Text dialog window

13. Design a Custom Color (Using Scrollbar) dialog window

14. Design a Stop Watch dialog window

15. Design a dialog window to Open Picture in picture-box

16. Design a dialog window to Student Information System


1. Define Visual Programming Language, how it is different from other Traditional
Programming Language
Ans. A Visual Programming Language (VPL) is a type of programming language that allows users
to create programs by manipulating graphical elements rather than writing text code. In VPLs, the
programming environment typically consists of visual elements like blocks, nodes, or flowcharts,
which represent programming constructs. These elements can be dragged, connected, and configured,
making it easier to build complex applications without the need for extensive text-based syntax.
Key Differences Between Visual Programming Language and Traditional Programming
Language

Visual Programming Language


Aspect Traditional Programming Language
(VPL)

Programming Graphical elements (blocks,


Text-based code (lines of syntax)
Style flowcharts, nodes)

Drag-and-drop, point-and-click Text editors, IDEs with syntax


User Interface
interaction highlighting

Often higher due to syntax and code


Learning Curve Lower, especially for beginners
structure

Can be harder to visualize, requires code-


Readability Often more intuitive, visual flow
reading skills

Limited; suited for specific tasks or More flexible, suitable for general-
Flexibility
domains purpose applications

Visual feedback on errors or flow Often requires familiarity with debugging


Debugging
issues tools

Game design, educational tools, IoT General-purpose software, complex


Use Cases
applications, prototyping applications, web development

Examples Scratch, Blockly, LabVIEW, Simulink Python, Java, C++, JavaScript

Pros and Cons of Visual Programming Languages


Pros:
• Easier Learning Curve: VPLs are accessible to beginners as they don’t require memorizing
complex syntax.
• Rapid Prototyping: Visual programs are often quicker to prototype since users can visualize
the entire process.
• Fewer Syntax Errors: Since users work with predefined blocks or visual elements, syntax
errors are minimized.
Cons:
• Limited Flexibility: VPLs may not offer the same versatility as traditional languages,
especially for large-scale or specialized applications.
• Scalability Issues: VPLs can become cluttered or difficult to manage for very complex
programs.
• Performance Limitations: VPLs are often optimized for simplicity and may lack the
performance optimizations found in traditional languages.
Examples of Visual Programming Languages
• Scratch: Aimed at teaching children to code through block-based visual programming.
• Blockly: Often used in educational environments, where users piece together code blocks to
form programs.
• LabVIEW: Used for data acquisition, instrument control, and industrial automation.
• Simulink: A graphical programming environment within MATLAB, widely used in
engineering fields for modeling and simulating systems.
In summary, VPLs make programming more accessible and visual but often sacrifice some flexibility
and scalability compared to traditional, text-based languages. They are highly useful in education,
prototyping, and fields where visual feedback and ease of use are prioritized.
2. Introduction of User Interface / Platform provided by VB6.0 with its different
Components and Features.
Ans. Visual Basic 6.0 (VB6.0) is a popular programming environment developed by Microsoft,
released in 1998 as part of the Visual Studio suite. It enables developers to create Windows-based
applications with a graphical user interface (GUI) by using a combination of visual design and code-
based functionality. VB6.0 is known for its ease of use and rapid application development (RAD)
capabilities, which make it ideal for beginners and professional developers alike.
Key Components and Features of the VB6.0 Interface
The VB6.0 interface consists of several key components that enable developers to design, code, and
debug applications efficiently.

1. Main VB6.0 Window


• The primary interface where developers organize and access all the components and tools
available in VB6.0.
• Contains the menu bar, toolbar, and workspace area.

2. Form Designer
• Central to VB6.0, the Form Designer allows developers to design the graphical interface of
applications by dragging and dropping controls onto forms.
• Each form represents a window or dialog box in the application.
• Developers can place components like buttons, text boxes, and labels onto forms to define the
appearance and layout of the interface.

3. Toolbox
• A panel that provides a set of pre-defined controls (UI components) that can be added to the
form.
• Common controls include:
o Command Button: Used for clickable actions.
o Text Box: Allows the user to input text.
o Label: Displays static text on the form.
o Combo Box: A drop-down list to select from predefined items.
o List Box: Shows a list of items.
o Picture Box: Allows images to be embedded on the form.
o Timer: Executes code at specified intervals.
o Scrollbar: Provides scrollable functionality for form content.
• Custom controls (ActiveX controls) can also be added to extend functionality.
4. Project Explorer
• Displays all the files and components associated with the current project.
• Shows the hierarchy of forms, modules, and class files within the application.
• Developers can navigate to specific files and open them by double-clicking in the Project
Explorer.

5. Properties Window
• Lists all the properties of the selected control or form.
• Developers can customize controls' attributes, such as size, color, font, position, and name,
without needing to write code.
• Properties update in real-time as changes are made, providing immediate visual feedback.

6. Code Editor
• The area where developers write the VB code to define the application’s logic and behavior.
• Organized by events, such as button clicks, text box input changes, or form loading.
• Supports syntax highlighting, indentation, and basic debugging features.
• Each control on a form has associated event handlers, making it easy to structure code by
actions.

7. Menu Editor
• Allows developers to create custom menus for the application, such as File, Edit, and Help
menus.
• Provides options to set up menu items, define keyboard shortcuts, and create nested submenus.

8. Debugging Tools
• VB6.0 includes a range of debugging tools, such as breakpoints, watches, and the Immediate
Window.
• The Immediate Window allows real-time execution of commands and expressions, useful for
testing code snippets.
• Breakpoints help pause the execution to examine variable states and step through the code.

9. Properties and Methods of Controls


• Every control in VB6.0 comes with properties (e.g., Text, Visible, Enabled) and methods (e.g.,
Show, Hide, Move).
• Methods allow interaction with controls through code, while properties define their
characteristics.
Additional Features of VB6.0
• Event-Driven Programming: VB6.0 is highly event-driven, meaning code is organized
around user and system events, making it easy to create interactive applications.
• Data Access: VB6.0 provides tools for accessing databases, including Data Controls, ADO
(ActiveX Data Objects), and DAO (Data Access Objects).
• ActiveX Controls: Developers can add custom controls to extend the functionality of standard
controls.
• OLE (Object Linking and Embedding): Enables integration with other applications, such as
embedding Excel sheets or Word documents into VB forms.
• Deployment Wizard: Facilitates the packaging and deployment of applications, including
handling dependencies and creating setup files.

Advantages of VB6.0
• Ease of Use: The drag-and-drop interface and pre-defined controls make VB6.0 accessible for
developers of all levels.
• Rapid Development: Ideal for quickly prototyping or developing small-to-medium
applications.
• Integrated Development Environment (IDE): The all-in-one IDE provides tools for
designing, coding, and debugging in a single interface.
VB6.0 was a popular choice for Windows applications due to its simplicity and RAD capabilities,
though it has been largely replaced by modern tools such as Visual Basic .NET and other frameworks
for Windows development.
3. Define TextBox, CommandButton, OptionButton, CheckBox, ListBox and
ComboBox with their important properties, events and methods.
Ans. In Visual Basic 6.0, various controls here to interact with users in different ways

1. TextBox
• Description: A TextBox allows users to enter and edit text.
• Properties:
o Text: Holds the text entered in the TextBox.
o MaxLength: Limits the number of characters allowed.
o PasswordChar: Masks the text for passwords.
o Enabled: Determines if the TextBox is active.
o Locked: Prevents editing without disabling it visually.
• Events:
o Change: Triggered when text is changed.
o KeyPress: Detects specific keys pressed while in the TextBox.
o GotFocus / LostFocus: Triggered when the TextBox gains or loses focus.
• Methods:
o SetFocus(): Moves the cursor to the TextBox.
o Clear(): Clears the TextBox content.

2. CommandButton
• Description: A CommandButton is a clickable button used to execute actions.
• Properties:
o Caption: Text displayed on the button.
o Enabled: Enables or disables the button.
o Visible: Controls visibility of the button.
o Default: Sets it as the default button, activated by pressing Enter.
o Cancel: Sets it as the cancel button, activated by pressing Esc.
• Events:
o Click: Triggered when the button is clicked.
o MouseDown / MouseUp: Detects when the mouse is pressed or released.
• Methods:
o SetFocus(): Sets the focus to the button.
o Refresh(): Redraws the button.
3. OptionButton
• Description: An OptionButton (Radio Button) allows users to select one option from a set of
mutually exclusive options.
• Properties:
o Caption: Text label beside the button.
o Value: Determines if the OptionButton is selected (True) or not (False).
o Enabled: Allows or prevents user interaction.
o Visible: Shows or hides the OptionButton.
• Events:
o Click: Triggered when the button is selected.
o GotFocus / LostFocus: Triggered when the OptionButton gains or loses focus.
• Methods:
o SetFocus(): Moves focus to the OptionButton.
o Refresh(): Redraws the OptionButton.

4. CheckBox
• Description: A CheckBox allows users to select multiple options independently (checked or
unchecked).
• Properties:
o Caption: Text label next to the CheckBox.
o Value: State of the CheckBox (Checked, Unchecked, or Grayed).
o Enabled: Enables or disables the CheckBox.
o Visible: Controls visibility of the CheckBox.
• Events:
o Click: Triggered when the CheckBox is selected or deselected.
o GotFocus / LostFocus: Triggered when the CheckBox gains or loses focus.
• Methods:
o SetFocus(): Moves focus to the CheckBox.
o Refresh(): Redraws the CheckBox.

5. ListBox
• Description: A ListBox displays a list of items from which users can select one or more items.
• Properties:
o List: The items contained in the ListBox.
o ListCount: The total number of items in the ListBox.
o ListIndex: Index of the currently selected item.
o MultiSelect: Determines if multiple selections are allowed.
o Enabled: Enables or disables the ListBox.
• Events:
o Click: Triggered when an item is selected.
o DblClick: Triggered on double-click of an item.
o KeyPress: Detects key presses while ListBox is in focus.
• Methods:
o AddItem: Adds a new item to the ListBox.
o RemoveItem: Removes a specified item.
o Clear(): Clears all items from the ListBox.
o SetFocus(): Sets focus to the ListBox.

6. ComboBox
• Description: A ComboBox is a drop-down list that allows users to select an item from a list or
type a custom entry.
• Properties:
o Text: Holds the selected or entered text.
o List: Contains the list of items in the ComboBox.
o ListCount: Number of items in the list.
o ListIndex: Index of the currently selected item.
o Style: Determines the ComboBox style (Drop-down, Drop-down List).
• Events:
o Click: Triggered when an item is selected.
o Change: Triggered when text in the ComboBox changes.
o DblClick: Triggered on double-click of an item.
o KeyPress: Detects key presses within the ComboBox.
• Methods:
o AddItem: Adds an item to the ComboBox.
o RemoveItem: Removes a specified item.
o Clear(): Clears all items in the ComboBox.
o SetFocus(): Moves focus to the ComboBox.
4. Write down different types of Database Connectivity’s and five methods of
Recordset.
Ans. Database Connectivity Types in Visual Basic 6.0 (VB6.0) refer to the various ways the
application can connect and interact with databases to retrieve, update, and manage data. Here are
some common methods of database connectivity in VB6.0:

Types of Database Connectivity


1. DAO (Data Access Objects)
o DAO is a high-level data access library mainly used for accessing MS Access databases
and managing Jet databases.
o Provides a simple interface for working with local databases and is suitable for smaller
applications.
2. ADO (ActiveX Data Objects)
o ADO is a more versatile and widely-used method for database connectivity in VB6.0,
especially for connecting to SQL Server, Oracle, and other relational databases.
o It allows connectivity through OLE DB providers and is efficient for handling large
datasets in server-based applications.
3. ODBC (Open Database Connectivity)
o ODBC provides a standardized way of connecting to different databases using drivers,
making it highly flexible and platform-independent.
o VB6.0 can use ODBC drivers to connect to various database types (such as SQL Server,
Oracle, and MySQL).
4. RDO (Remote Data Objects)
o RDO is another method for connecting to remote databases, particularly for client-
server applications.
o It is primarily used for applications that require remote data access and is compatible
with ODBC.
5. OLE DB (Object Linking and Embedding Database)
o OLE DB is a set of COM interfaces that allow VB6.0 to access data from various
sources, including relational databases, spreadsheets, and text files.
o ADO typically leverages OLE DB as its underlying mechanism.

Five Common Methods of the Recordset Object in VB6.0


The Recordset object in VB6.0 (typically used with ADO or DAO) represents a set of records from a
database and provides methods for navigating and manipulating data.
1. Open
o Opens the Recordset, allowing the application to retrieve data from a table, query, or
SQL statement.
o Syntax: Recordset.Open Source, ActiveConnection, CursorType, LockType, Options
2. AddNew
o Adds a new record to the Recordset.
o Syntax: Recordset.AddNew
o After calling AddNew, you can set values for the new record fields before calling
Update.
3. Update
o Saves changes made to the current record, such as those added by AddNew or edited
fields.
o Syntax: Recordset.Update
4. MoveNext
o Moves the current record pointer to the next record in the Recordset.
o Useful for looping through records in a Recordset.
o Syntax: Recordset.MoveNext
5. Close
o Closes the Recordset, releasing system resources.
o Syntax: Recordset.Close

These methods make it easier to handle and manipulate database records, enabling VB6.0 applications
to perform data operations like adding, updating, navigating, and closing records in a database. Each
method is part of the essential toolkit for interacting with data through a Recordset object.
5. Design a Calculator dialog window

Tushar Kumar (1221783011094)


Coding

Dim Fvalue, Svalue As Integer


Dim op As String

Private Sub cmd00_Click()


txtInputBox.Text = txtInputBox.Text + "00"
End Sub

Private Sub cmd1_Click()


txtInputBox.Text = txtInputBox.Text + "1"
End Sub

Private Sub cmd2_Click()


txtInputBox.Text = txtInputBox.Text + "2"
End Sub

Private Sub cmd3_Click()


txtInputBox.Text = txtInputBox.Text + "3"
End Sub

Private Sub cmd4_Click()


txtInputBox.Text = txtInputBox.Text + "4"
End Sub

Private Sub cmd5_Click()


txtInputBox.Text = txtInputBox.Text + "5"
End Sub

Private Sub cmd6_Click()


txtInputBox.Text = txtInputBox.Text + "6"
End Sub

Private Sub cmd7_Click()


txtInputBox.Text = txtInputBox.Text + "7"
End Sub

Private Sub cmd8_Click()


txtInputBox.Text = txtInputBox.Text + "8"
End Sub

Private Sub cmd9_Click()


txtInputBox.Text = txtInputBox.Text + "9"
End Sub

Private Sub cmd0_Click()


txtInputBox.Text = txtInputBox.Text + "0"
End Sub

Tushar Kumar (1221783011094)


Private Sub cmdDot_Click()
txtInputBox.Text = txtInputBox.Text + "."
End Sub

Private Sub cmdClear_Click()


txtInputBox.Text = "0"
End Sub

Private Sub cmdDiv_Click()


op = "/"
InputData
End Sub

Private Sub cmdModulo_Click()


op = "Mod"
InputData
End Sub

Private Sub cmdMul_Click()


op = "*"
InputData
End Sub

Private Sub cmdSub_Click()


op = "-"
InputData
End Sub

Private Sub cmdSum_Click()


op = "+"
InputData
End Sub

Private Sub cmdEqual_Click()


Svalue = Val(txtInputBox.Text)
If op = "Mod" Then
txtInputBox.Text = Fvalue Mod Svalue
ElseIf op = "+" Then
txtInputBox.Text = Fvalue + Svalue
ElseIf op = "-" Then
txtInputBox.Text = Fvalue - Svalue
ElseIf op = "*" Then
txtInputBox.Text = Fvalue * Svalue

ElseIf op = "/" Then


If Svalue = 0 Then
MsgBox "We cannot divisible by 0."
Else
txtInputBox.Text = Fvalue / Svalue
End If
End If

Tushar Kumar (1221783011094)


End Sub

Private Sub cmdDelete_Click()


If txtInputBox.Text = "" Then
MsgBox "TextBox Is Empty"
Else
txtInputBox.Text = Left(txtInputBox.Text, Len(txtInputBox.Text) - 1)
End If
End Sub

'------------------------------------User Define Procedure-------------------------


Public Sub InputData()
If (txtInputBox.Text <> "") Then
Fvalue = Val(txtInputBox.Text)
txtInputBox.Text = ""
txtInputBox.SetFocus
End If
End Sub

Tushar Kumar (1221783011094)


6. Design a Font dialog window

Tushar Kumar (1221783011094)


Coding

Private Sub chkStrikeout_Click()


If chkStrikeout.Value = 1 Then
lblPreview.FontStrikethru = True
Else
lblPreview.FontStrikethru = False
End If
End Sub

Private Sub chkUnderline_Click()


If chkUnderline.Value = 1 Then
lblPreview.FontUnderline = True
Else
lblPreview.FontUnderline = False
End If
End Sub

Private Sub cmdCancel_Click()


Unload Me
End Sub

Private Sub Form_Load()


lstFont.ListIndex = 0
lstFontStyle.ListIndex = 0
lstSize.ListIndex = 3
End Sub

Private Sub lstFont_Click()


txtFont.Text = lstFont.Text
End Sub

Private Sub lstFontStyle_Click()


txtFontStyle.Text = lstFontStyle.Text
End Sub

Private Sub lstSize_Click()


txtSize.Text = lstSize.Text
End Sub

Private Sub txtFont_Change()


If txtFont.Text <> "" Then
lblPreview.Font = txtFont.Text
End If
End Sub

Private Sub txtSize_Change()


lblPreview.FontSize = txtSize.Text
End Sub

Tushar Kumar (1221783011094)


Private Sub txtFontStyle_Change()
Select Case txtFontStyle.Text
Case "Regular"
lblPreview.FontBold = False
lblPreview.FontItalic = False
Case "Bold Oblique"
lblPreview.FontItalic = True
lblPreview.FontBold = True
End Select
If txtFontStyle.Text = "Bold" Then
lblPreview.FontBold = True
lblPreview.FontItalic = False
ElseIf txtFontStyle.Text = "Oblique" Then
lblPreview.FontItalic = True
lblPreview.FontBold = False
End If
End Sub

Private Sub VScroll1_Change()


txtSize.Text = VScroll1.Value
End Sub

Tushar Kumar (1221783011094)


7. Design a Color Palette dialog window

Tushar Kumar (1221783011094)


Coding

Private Sub cmdColor1_Click()


txtPreview.ForeColor = cmdColor1.BackColor
End Sub

Private Sub cmdColor2_Click()


txtPreview.ForeColor = cmdColor2.BackColor
End Sub

Private Sub cmdColor3_Click()


txtPreview.ForeColor = cmdColor3.BackColor
End Sub

Private Sub cmdColor4_Click()


txtPreview.ForeColor = cmdColor4.BackColor
End Sub

Private Sub cmdColor5_Click()


txtPreview.ForeColor = cmdColor5.BackColor
End Sub

Private Sub cmdColor6_Click()


txtPreview.ForeColor = cmdColor6.BackColor
End Sub

Private Sub cmdColor7_Click()


txtPreview.ForeColor = cmdColor7.BackColor
End Sub

Private Sub cmdColor8_Click()


txtPreview.ForeColor = cmdColor8.BackColor
End Sub

Private Sub cmdColor9_Click()


txtPreview.ForeColor = cmdColor9.BackColor
End Sub

Private Sub txtColor1_Click()


txtPreview.BackColor = txtColor1.BackColor
End Sub

Private Sub txtColor2_Click()


txtPreview.BackColor = txtColor2.BackColor
End Sub

Private Sub txtColor3_Click()


txtPreview.BackColor = txtColor3.BackColor
End Sub

Tushar Kumar (1221783011094)


Private Sub txtColor4_Click()
txtPreview.BackColor = txtColor4.BackColor
End Sub

Private Sub txtColor5_Click()


txtPreview.BackColor = txtColor5.BackColor
End Sub

Private Sub txtColor6_Click()


txtPreview.BackColor = txtColor6.BackColor
End Sub

Private Sub txtColor7_Click()


txtPreview.BackColor = txtColor7.BackColor
End Sub

Private Sub txtColor8_Click()


txtPreview.BackColor = txtColor8.BackColor
End Sub

Private Sub txtColor9_Click()


txtPreview.BackColor = txtColor9.BackColor
End Sub

Tushar Kumar (1221783011094)


8. Design a Login Form dialog window

Tushar Kumar (1221783011094)


Coding

Dim userId, password As Integer

Private Sub chkPass_Click()


If chkPass.Value = 1 Then
txtPassword.PasswordChar = ""
Else
txtPassword.PasswordChar = "*"
End If
End Sub

Private Sub cmdCancel_Click()


End
End Sub

Private Sub cmdLogin_Click()


If txtUsername.Text = userId And txtPassword.Text = password Then
MsgBox "Login SuccessFul", vbInformation, "Login Form"
Else
MsgBox "Invalid Username and Password", vbExclamation, "Login Form"
End If
End Sub

Private Sub Form_Load()


userId = "Tushar01"
password = "1234"
End Sub

Tushar Kumar (1221783011094)


9. Design a Registration Form dialog window

Tushar Kumar (1221783011094)


Coding
Private Sub cmdAddNew_Click()
Data1.Recordset.AddNew
DTPicker1.Value = Date
End Sub

Private Sub cmdDeleteRecord_Click()


Data1.Recordset.Delete
Data1.Refresh
End Sub

Private Sub cmdExit_Click()


If MsgBox("Are you Sure to Exit", vbQuestion + vbYesNo, "Form Close Confirmation") =
vbYes Then
Unload Me
End If
End Sub

Private Sub cmdMoveFirst_Click()


Data1.Recordset.MoveFirst
End Sub

Private Sub cmdMoveLast_Click()


Data1.Recordset.MoveLast
End Sub

Private Sub cmdMoveNext_Click()


Data1.Recordset.MoveNext
End Sub

Private Sub cmdMovePrevious_Click()


Data1.Recordset.MovePrevious
End Sub

Private Sub cmdShow_Click()


frmDataGrid.Show
End Sub

Private Sub cmdSubmit_Click()


If optYes.Value = True And (txtAadhaarNumber.Text = "" Or Len(txtAadhaarNumber.Text)
<> 12) Then
MsgBox "Please Enter Correct Aadhaar Number", vbCritical, "Validation"
ElseIf cboIdentityCard.Text = "" Then
MsgBox "Please Select Type of Identity Card", vbExclamation, "Validation"
cboIdentityCard.SetFocus
ElseIf txtIdentityNumber.Text = "" Then
MsgBox "Please Enter Identity Number", vbExclamation, "Validation"
txtIdentityNumber.SetFocus
ElseIf txtCandidateName.Text = "" Then
MsgBox "Please Enter Candidate Name", vbExclamation, "Validation"
txtCandidateName.SetFocus

Tushar Kumar (1221783011094)


ElseIf cboGender.Text = "" Then
MsgBox "Please Select Gender", vbExclamation, "Validation"
cboGender.SetFocus
ElseIf DTPicker1.Value >= Date Then
MsgBox "Please Select Correct DOB ", vbExclamation, "Validation"
DTPicker1.SetFocus
ElseIf txtFather.Text = "" Then
MsgBox "Please Enter Father's Name", vbExclamation, "Validation"
txtFather.SetFocus
ElseIf txtMother.Text = "" Then
MsgBox "Please Enter Mother's Name", vbExclamation, "Validation"
txtMother.SetFocus
ElseIf txtFather.Text = "" Then
MsgBox "Please Enter Father's Name", vbExclamation, "Validation"
txtFather.SetFocus
ElseIf cboQualification.Text = "" Then
MsgBox "Please Select Qualification", vbExclamation, "Validation"
cboQualification.SetFocus
ElseIf txtMobileNumber.Text = "" Or Len(txtMobileNumber.Text) <> 10 Then
MsgBox "Please Enter Correct Mobile Number", vbCritical, "Validation"
txtMobileNumber.SetFocus
ElseIf txtEmail.Text = "" Then
MsgBox "Please Enter Email ID", vbExclamation, "Validation"
txtEmail.SetFocus
ElseIf txtPassword = "" Then
MsgBox "Please Create Password ", vbExclamation, "Validation"
txtPassword.SetFocus
ElseIf txtPassword.Text <> txtConfirmPassword.Text Then
MsgBox "Confirm Password Mismatch", vbCritical, "Confirm Password"
ElseIf txtPassword.Text = txtConfirmPassword.Text And txtMobileNumber.Text <> "" And
Len(txtMobileNumber.Text) = 10 Then
Data1.Recordset.Update
MsgBox "Submitted Sucessfully !", vbInformation, "Submission Sucessfull "
Unload Me
End If
End Sub

Private Sub Frame2_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub optNo_Click()


If optNo = True Then
txtAadhaarNumber.Enabled = False
End If
End Sub

Private Sub optYes_Click()


If optYes = True Then
txtAadhaarNumber.Enabled = True
End If

Tushar Kumar (1221783011094)


End Sub

Private Sub txtAadhaarNumber_KeyPress(KeyAscii As Integer)


If Chr$(KeyAscii) >= "a" And Chr$(Ascii) <= "z" Then
KeyAscii = KeyAscii - 32
End If
If (KeyAscii) >= vbKeyA And (KeyAscii) <= vbKeyZ Then
MsgBox "Characters are Not Allowed .", vbCritical, "Validation"
KeyAscii = "0"
End If
End Sub

Private Sub txtCandidateName_KeyPress(KeyAscii As Integer)


If (KeyAscii) >= vbKey0 And (KeyAscii) <= vbKey9 Then
MsgBox "Numeric Values are Not Allowed .", vbCritical, "Validation"
KeyAscii = "0"
End If
If Chr$(KeyAscii) >= "a" And Chr$(Ascii) <= "z" Then
KeyAscii = KeyAscii - 32
End If
End Sub

Private Sub txtFather_KeyPress(KeyAscii As Integer)


If (KeyAscii) >= vbKey0 And (KeyAscii) <= vbKey9 Then
MsgBox "Numeric Values are Not Allowed .", vbCritical, "Validation"
KeyAscii = "0"
End If
If Chr$(KeyAscii) >= "a" And Chr$(Ascii) <= "z" Then
KeyAscii = KeyAscii - 32
End If
End Sub

Private Sub txtMobileNumber_KeyPress(KeyAscii As Integer)


If Chr$(KeyAscii) >= "a" And Chr$(Ascii) <= "z" Then
KeyAscii = KeyAscii - 32
End If
If (KeyAscii) >= vbKeyA And (KeyAscii) <= vbKeyZ Then
MsgBox "Characters are Not Allowed .", vbCritical, "Validation"
KeyAscii = "0"
End If
End Sub

Private Sub txtMother_KeyPress(KeyAscii As Integer)


If (KeyAscii) >= vbKey0 And (KeyAscii) <= vbKey9 Then
MsgBox "Numeric Values are Not Allowed .", vbCritical, "Validation"
KeyAscii = "0"
End If
If Chr$(KeyAscii) >= "a" And Chr$(Ascii) <= "z" Then
KeyAscii = KeyAscii - 32
End If
End Sub

Tushar Kumar (1221783011094)


Private Sub txtIdentityNumber_KeyPress(KeyAscii As Integer)
If Chr$(KeyAscii) >= "a" And Chr$(Ascii) <= "z" Then
KeyAscii = KeyAscii - 32
End If
End Sub

Tushar Kumar (1221783011094)


10. Design a Table Create (Using Looping) dialog window

Tushar Kumar (1221783011094)


Coding

Private Sub cmdDoUntil_Click()


If txtEnterValue.Text = "" Then
MsgBox "Please Enter Number for Table."
txtEnterValue.SetFocus
Else
lstPrintTable.Clear
Table_Count = 1
Do Until (Table_Count > 10)
lstPrintTable.AddItem Val(txtEnterValue.Text) & " X " & Table_Count & " = " & Table_Count
* Val(txtEnterValue.Text)
Table_Count = Table_Count + 1
Loop
End If
End Sub

Private Sub cmdDoWhile_Click()


If txtEnterValue.Text = "" Then
MsgBox "Please Enter Number for Table."
txtEnterValue.SetFocus
Else
lstPrintTable.Clear
Table_Count = 1
Do While (Table_Count <= 10)
lstPrintTable.AddItem Val(txtEnterValue.Text) & " X " & Table_Count & " = " & Table_Count
* Val(txtEnterValue.Text)
Table_Count = Table_Count + 1
Loop
End If
End Sub

Private Sub cmdForLoop_click()


If txtEnterValue.Text = "" Then
MsgBox "Please Enter Number for Table."
txtEnterValue.SetFocus
Else
lstPrintTable.Clear
For Table_Count = 1 To 10 Step 1
lstPrintTable.AddItem Val(txtEnterValue.Text) & " X " & Table_Count & " = " & Table_Count
* Val(txtEnterValue.Text)
Next
End If
End Sub

Private Sub txtEnterValue_Click()


txtEnterValue.Text = ""
End Sub

Tushar Kumar (1221783011094)


11. Design a Traffic Light dialog window

Tushar Kumar (1221783011094)


Coding

Private Sub Timer1_Timer()


Static Change As Integer
Change = Change + 1
If Change = 1 Then
ShapeRed.FillColor = &HFF&
ShapeYellow.FillColor = &H80000003
ShapeGreen.FillColor = &H80000003
lblStatus.Caption = "Stop"
lblStatus.ForeColor = &HFF&
ElseIf Change = 2 Then
ShapeRed.FillColor = &H80000003
ShapeYellow.FillColor = &HFFFF&
ShapeGreen.FillColor = &H80000003
lblStatus.Caption = "Ready"
lblStatus.ForeColor = &HFFFF&
ElseIf Change = 3 Then
ShapeRed.FillColor = &H80000003
ShapeYellow.FillColor = &H80000003
ShapeGreen.FillColor = &HFF00&
lblStatus.Caption = "Go"
lblStatus.ForeColor = &HFF00&
Change = 0
End If
End Sub

Tushar Kumar (1221783011094)


12. Design a Marquee Text dialog window

Tushar Kumar (1221783011094)


Coding

Dim Click As String

Private Sub cmdStop_Click()


If cmdStop.Caption = "Stop" Then
Timer1.Enabled = False
cmdStop.Caption = "Start"
Else: cmdStop.Caption = "Start"
Timer1.Enabled = True
cmdStop.Caption = "Stop"
End If
End Sub

Private Sub cmdTopRight_Click()


Click = "TopRight"
End Sub

Private Sub cmdHorizontal_Click()


Click = "Horizontal"
End Sub

Private Sub cmdTopLeft_Click()


Click = "TopLeft"
End Sub

Private Sub cmdVertically_Click()


Click = "Vertical"
End Sub

Private Sub Timer1_Timer()


Static Direction As Integer
If Click = "Horizontal" Then
If (Direction = 0) Then
lblStatus.Caption = "Move Left To Right"
Label1.Left = Label1.Left + 1000
If Label1.Left > Me.ScaleWidth - Label1.Width Then
Direction = 1
End If
Else:
lblStatus.Caption = "Move Right To Left"
Label1.Left = Label1.Left - 1000
If Label1.Left <= 0 Then
Direction = 0
End If
End If
ElseIf Click = "Vertical" Then
If (Direction = 0) Then
lblStatus.Caption = "Move Top To Bottom"
Label1.Top = Label1.Top + 1000

Tushar Kumar (1221783011094)


If Label1.Top > Me.ScaleHeight - Label1.Height Then
Direction = 1
End If
Else:
lblStatus.Caption = "Move Bottom To Top"
Label1.Top = Label1.Top - 1000
If Label1.Top <= 0 Then
Direction = 0
End If
End If
ElseIf Click = "TopRight" Then
lblStatus.Caption = ""
If (Direction = 0) Then
Label1.Left = Label1.Left - 2000
Label1.Top = Label1.Top + 1000
If Label1.Left <= 0 Or Label1.Top > Me.ScaleHeight - Label1.Height Then
Direction = 1
End If
Else:
Label1.Left = Label1.Left + 2000
Label1.Top = Label1.Top - 1000
If Label1.Left > Me.ScaleWidth - Label1.Width Or Label1.Top <= 0 Then
Direction = 0
End If
End If
ElseIf Click = "TopLeft" Then
lblStatus.Caption = ""
If (Direction = 0) Then
Label1.Left = Label1.Left + 2000
Label1.Top = Label1.Top + 1000
If Label1.Left > Me.ScaleWidth - Label1.Width Or Label1.Top >
Me.ScaleHeight - Label1.Height Then
Direction = 1
End If
Else:
Label1.Left = Label1.Left - 2000
Label1.Top = Label1.Top - 1000
If Label1.Left <= 0 Or Label1.Top <= 0 Then
Direction = 0
End If
End If
End If
End Sub

Tushar Kumar (1221783011094)


13. Design a Custom Color (Using Scrollbar) dialog window

Tushar Kumar (1221783011094)


Coding
Private Sub cmdPutBackcolor_Click()
txtColorPreview.BackColor = txtMakeColor.BackColor
End Sub

Private Sub cmdPutFontcolor_Click()


txtColorPreview.ForeColor = txtMakeColor.BackColor
End Sub

Private Sub HScrollRed_Change()


txtMakeColor.BackColor = RGB(Val(HScrollRed.Value), Val(HScrollGreen.Value),
Val(HScrollBlue.Value))
End Sub

Private Sub HScrollGreen_Change()


txtMakeColor.BackColor = RGB(Val(HScrollRed.Value), Val(HScrollGreen.Value),
Val(HScrollBlue.Value))
End Sub

Private Sub HScrollBlue_Change()


txtMakeColor.BackColor = RGB(Val(HScrollRed.Value), Val(HScrollGreen.Value),
Val(HScrollBlue.Value))
End Sub

Tushar Kumar (1221783011094)


14. Design a Stop Watch dialog window

Tushar Kumar (1221783011094)


Coding

Dim LapCount As Integer


Dim MiliSec As Integer
Dim Sec As Integer
Dim Min As Integer

Private Sub cmdClearHistory_Click()


lstLapHistory.Clear
End Sub

Private Sub cmdPause_Click()


Timer1.Enabled = False
End Sub

Private Sub cmdResume_Click()


Timer1.Enabled = True
End Sub

Private Sub cmdStart_Click()


Timer1.Enabled = True
End Sub

Private Sub cmdLap_Click()


LapCount = LapCount + 1
lstLapHistory.AddItem LapCount & ". " & lblTime.Caption
End Sub

Private Sub cmdStop_Click()


lblTime.Caption = "00:00.00"
MiliSec = 0
Sec = 0
Min = 0
Timer1.Enabled = False
cmdStart.SetFocus
End Sub

Private Sub Timer1_Timer()


MiliSec = MiliSec + 1
If MiliSec = 60 Then
Sec = Sec + 1
MiliSec = 0
If Sec = 60 Then
Min = Min + 1
Sec = 0
End If
End If
lblTime.Caption = Format$(Min, "00") & ":" & Format$(Sec, "00") & "." & Format$(MiliSec,
"00")
End Sub

Tushar Kumar (1221783011094)


15. Design a dialog window to Open Picture in picture-box

Tushar Kumar (1221783011094)


Coding

Dim strFullPath As String

Private Sub dirSelectPath_Change()


fileSelectFile.Path = dirSelectPath.Path
End Sub

Private Sub dirSelectPath_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As


Single)
Updatepath
End Sub

Private Sub drvSelectDrive_Change()


dirSelectPath.Path = drvSelectDrive.Drive
End Sub

Private Sub fileSelectFile_Click()


picDisplay.Picture = LoadPicture(strFullPath & "\" & fileSelectFile.FileName)
picDisplay.AutoRedraw = True
picDisplay.PaintPicture picDisplay.Picture, 0, 0, picDisplay.ScaleWidth,
picDisplay.ScaleHeight, 0, 0
End Sub

Private Sub Updatepath()


strFullPath = dirSelectPath.Path
txtCurrentPath.Text = strFullPath
End Sub

Tushar Kumar (1221783011094)


16. Design a dialog window to Student Information System

Tushar Kumar (1221783011094)


Private Sub cmdFetchFees_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connection


cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=StudentInformationSystem.mdb"

Dim rollNumber As String


rollNumber = txtRollNumber.Text

Set rs = New ADODB.Recordset


rs.Open "SELECT Total_Fees, Fees_Paid,Pending_Fees, Other_Fine, Payment_date,
Late_Fee_Fine, Course_Code FROM Fees WHERE Roll_Number = '" & rollNumber & "'",
cn, adOpenStatic
If Not rs.EOF Then
txtTotalFees.Text = rs!Total_Fees
txtFeesPaid.Text = rs!Fees_Paid
txtPendingFees.Text = rs!Pending_Fees
txtOtherFine.Text = rs!Other_Fine
DTPicker1.Value = rs!Payment_date
txtFine.Text = rs!Late_Fee_Fine
txtFeesCourseCode.Text = rs!Course_Code
Else
MsgBox "Not Find!"
End If
rs.Close
cn.Close
End Sub

Tushar Kumar (1221783011094)


Tushar Kumar (1221783011094)
Coding

Private Sub cboCategory_Click()


If cboCategory.Text = "Under Graduate" Then
cboCourseName.Clear
cboCourseName.AddItem "BA"
cboCourseName.AddItem "BBA"
cboCourseName.AddItem "BCA"
ElseIf cboCategory.Text = "Post Graduate" Then
cboCourseName.Clear
cboCourseName.AddItem "MA"
cboCourseName.AddItem "MBA"
cboCourseName.AddItem "MCA"
Else: cboCourseName.Clear
End If
End Sub

Private Sub cboCourseName_Click()


txtCourseCode.Text = "DAV" & cboCourseName.Text & "2024MDU"
If cboCourseName.Text = "BA" Or cboCourseName.Text = "BBA" Or cboCourseName.Text
= "BCA" Or cboCourseName.Text = "BCom" Then
txtDuration.Text = "3 years"
ElseIf cboCourseName.Text = "MA" Or cboCourseName.Text = "MBA" Or
cboCourseName.Text = "MCA" Or cboCourseName.Text = "MCom" Then
txtDuration.Text = "2 years"
End If
If cboCourseName.Text = "BA" Then
txtCourseFees.Text = "39027"
ElseIf cboCourseName.Text = "BBA" Then
txtCourseFees.Text = "1,01,114/-"
ElseIf cboCourseName.Text = "BCA" Then
txtCourseFees.Text = "1,17,904/-"
ElseIf cboCourseName.Text = "MA" Then
txtCourseFees.Text = "51,238"
ElseIf cboCourseName.Text = "MBA" Then
txtCourseFees.Text = "75158/-"
ElseIf cboCourseName.Text = "MCA" Then
txtCourseFees.Text = "76,678/-"
End If
End Sub

Private Sub cboSelectYear_Click()


If cboCourseName.Text = "BA" And cboSelectYear.Text = "1st Year" Then
txtYearlyFees.Text = "13,719/-"
ElseIf cboCourseName.Text = "BA" And cboSelectYear.Text = "2nd Year" Then
txtYearlyFees.Text = "12,529/-"
ElseIf cboCourseName.Text = "BA" And cboSelectYear.Text = "3rd Year" Then
txtYearlyFees.Text = "12,779/-"
ElseIf cboCourseName.Text = "BBA" And cboSelectYear.Text = "1st Year" Then
txtYearlyFees.Text = "34,278/-"

Tushar Kumar (1221783011094)


ElseIf cboCourseName.Text = "BBA" And cboSelectYear.Text = "2nd Year" Then
txtYearlyFees.Text = "32,158/-"
ElseIf cboCourseName.Text = "BBA" And cboSelectYear.Text = "3rd Year" Then
txtYearlyFees.Text = "34,678/-"
ElseIf cboCourseName.Text = "BCA" And cboSelectYear.Text = "1st Year" Then
txtYearlyFees.Text = "39,828/-"
ElseIf cboCourseName.Text = "BCA" And cboSelectYear.Text = "2nd Year" Then
txtYearlyFees.Text = "37,788/-"
ElseIf cboCourseName.Text = "BCA" And cboSelectYear.Text = "3rd Year" Then
txtYearlyFees.Text = "40,288/-"
ElseIf cboCourseName.Text = "MA" And cboSelectYear.Text = "1st Year" Then
txtYearlyFees.Text = "25,969/-"
ElseIf cboCourseName.Text = "MA" And cboSelectYear.Text = "2nd Year" Then
txtYearlyFees.Text = "25,269/-"
ElseIf cboCourseName.Text = "MBA" And cboSelectYear.Text = "1st Year" Then
txtYearlyFees.Text = "38,149/-"
ElseIf cboCourseName.Text = "MBA" And cboSelectYear.Text = "2nd Year" Then
txtYearlyFees.Text = "37,009/-"
ElseIf cboCourseName.Text = "MCA" And cboSelectYear.Text = "1st Year" Then
txtYearlyFees.Text = "38,689/-"
ElseIf cboCourseName.Text = "MCA" And cboSelectYear.Text = "2nd Year" Then
txtYearlyFees.Text = "37,989/-"
End If
End Sub

Private Sub cboSemester_Click()


If txtCourseName.Text = "BCA" And cboSemester.Text = "1" Then
cboSubject.Clear
cboSubject.AddItem "Computer Fundamental"
cboSubject.AddItem "PC Software"
cboSubject.AddItem "Mathematics"
cboSubject.AddItem "Logic Organization of Computer"
cboSubject.AddItem "Practical Sofware Lab"
ElseIf txtCourseName.Text = "BCA" And cboSemester.Text = "2" Then
cboSubject.Clear
cboSubject.AddItem "C Programming"
cboSubject.AddItem "Logic Organization of Computer - II"
cboSubject.AddItem "Mathematical Foundations of Computer Science"
cboSubject.AddItem "Structured System Analysis and Design"
cboSubject.AddItem "Practical Sofware Lab"
ElseIf txtCourseName.Text = "BCA" And cboSemester.Text = "3" Then
cboSubject.Clear
cboSubject.AddItem "Operating System"
cboSubject.AddItem "Data Structure - I"
cboSubject.AddItem "Introduction to database System"
cboSubject.AddItem "Communication skill (English)"
cboSubject.AddItem "Practical Sofware Lab"
ElseIf txtCourseName.Text = "BCA" And cboSemester.Text = "4" Then
cboSubject.Clear
cboSubject.AddItem "Web Designing"
cboSubject.AddItem "Data Structure - II"

Tushar Kumar (1221783011094)


cboSubject.AddItem "OOPS"
cboSubject.AddItem "Software Engineering"
cboSubject.AddItem "Practical Sofware Lab"
ElseIf txtCourseName.Text = "BCA" And cboSemester.Text = "5" Then
cboSubject.Clear
cboSubject.AddItem "MIS"
cboSubject.AddItem "Computer Graphics"
cboSubject.AddItem "Data Communication and Networking"
cboSubject.AddItem "Visual Basic"
cboSubject.AddItem "Practical Sofware Lab"
ElseIf txtCourseName.Text = "BCA" And cboSemester.Text = "6" Then
cboSubject.Clear
cboSubject.AddItem "Artificial Intelligence"
cboSubject.AddItem "E.Commerce"
cboSubject.AddItem ".Net"
cboSubject.AddItem "Java"
cboSubject.AddItem "Practical Sofware Lab"
Else: cboSubject.Clear
End If
End Sub

Private Sub cboSubject_click()


txtSubCode.Text = txtCourseName.Text & "0" & cboSemester.Text & "0" &
cboSubject.ListIndex
If cboSubject.Text = "Practical Sofware Lab" Then
txtCategory.Text = "Practical"
txtMarks.Text = "100"
Else: txtCategory.Text = "Theory"
txtMarks.Text = "100"
End If
End Sub

Private Sub cmdNext_Click()


txtCourseName.Text = cboCourseName.Text
txtSubCourseCode.Text = txtCourseCode.Text
End Sub

Private Sub txtCourseName_Change()


txtSubCourseCode.Text = "DAV" & txtCourseName.Text & "2024MDU"
If txtCourseName.Text = "BA" Or txtCourseName.Text = "BBA" Or txtCourseName.Text =
"BCA" Then
cboSemester.Clear
cboSemester.AddItem "1"
cboSemester.AddItem "2"
cboSemester.AddItem "3"
cboSemester.AddItem "4"
cboSemester.AddItem "5"
cboSemester.AddItem "6"
ElseIf txtCourseName.Text = "MA" Or txtCourseName.Text = "MBA" Or
txtCourseName.Text = "MCA" Then
cboSemester.Clear

Tushar Kumar (1221783011094)


cboSemester.AddItem "1"
cboSemester.AddItem "2"
cboSemester.AddItem "3"
cboSemester.AddItem "4"
Else: cboSemester.Clear
End If
End Sub

Private Sub txtDuration_Change()


If txtDuration.Text = "2 years" Then
cboSelectYear.Clear
cboSelectYear.Clear
cboSelectYear.AddItem "1st Year"
cboSelectYear.AddItem "2nd Year"
ElseIf txtDuration.Text = "3 years" Then
cboSelectYear.Clear
cboSelectYear.Clear
cboSelectYear.AddItem "1st Year"
cboSelectYear.AddItem "2nd Year"
cboSelectYear.AddItem "3rd Year"
End If
End Sub

Tushar Kumar (1221783011094)

You might also like