Welcome to ADO.NET Access 2003—your ultimate hub for VB.NET and ADO.NET programming excellence. Discover in-depth tutorials, practical code samples, and expert troubleshooting guides covering a broad range of topics—from building robust WinForms applications and seamless MS Access integration to working with SQL Server, MySQL, and advanced tools like WebView2 and Crystal Reports. Whether you're a beginner or a seasoned developer, our step-by-step articles are designed to empower you to optimize.

Looking for MS Access Developer❓❓

Application developer

Post Page Advertisement [Top]

📘 

Visual Basic .NET 

OOP Tutorial

Learn Classes, Inheritance & Email Validation

VB.NET OOP
Visual Basic 2010 OOP

Object-Oriented Programming (OOP) has revolutionized how Visual Basic (VB) applications are built, transforming traditional procedural code into modular, reusable, and scalable software. In this post, you’ll learn how OOP is implemented in Visual Basic .NET, with a hands-on project to validate email formats.

🧠 What Is OOP?

OOP (Object-Oriented Programming) is a programming paradigm centered around the concept of objects, which contain both data (properties) and behaviors (methods). VB.NET is a fully OOP language, allowing you to:

  • Encapsulate logic into classes.

  • Reuse code via inheritance.

  • Customize behavior using polymorphism.

✅ Four Main OOP Concepts in VB.NET

  1. Abstraction
    Hide complexity by modeling real-world entities as objects.

  2. Encapsulation
    Keep data safe by restricting access and grouping with related behaviors.

  3. Polymorphism
    Use the same method name across different objects, with different behavior.

  4. Inheritance
    Reuse logic by deriving new classes from base classes.

🧱 OOP in Action: Email Format Validator in VB.NET

Let’s build a simple Windows Forms application that checks if a user-entered email address is in valid format.

👨‍🏫 Project Overview

  • Name: EmailFormatValidation

  • Platform: Visual Basic 2010 (.NET Framework)

  • Goal: Validate the presence of @ and . in an email address.

🖥️ Form Design

Control Type        Name                    Text
LabelLabel1Name
LabelLabel2E-mail
TextBoxTxtName[empty]
TextBoxTxtEmail[empty]
ButtonBtnValidValidate E-mail

✍ VB.NET Code Example


  Private Sub BtnValid_Click(sender As Object, e As EventArgs) Handles BtnValid.Click 
  	Dim X As Integer = TxtEmail.Text.IndexOf("@") 
  		If X >= 1 Then 
  			Dim Y As Integer = TxtEmail.Text.IndexOf(".", X) 
  		If Y < 1 Then 
  			MsgBox("Invalid E-mail Address") 
  		Else 
  			MsgBox("Valid E-mail Address Format") 
  		End If 
  		Else 
  			MsgBox("Invalid E-mail Address") 
  		End If 
  End Sub
  

Explanation:

  • IndexOf("@"): Checks if '@' exists and is not at the first position.

  • IndexOf(".", X): Ensures '.' comes after '@'.

  • Shows success or error message based on these conditions.

🎓 Homework / Practice Task

  1. Design this app in Visual Basic 2010 and test various input cases.

  2. Explore what happens when the email format is partially correct.

  3. Try extending it to use Regular Expressions for better validation.

🧩 OOP Lesson Index

🔹 Classes Introduction [Source code example - ms access development]
🔹 Properties & Methods
🔹 Sub vs. Function
🔹 Overloading & Inheritance
🔹 Access Modifiers
🔹 Real OOP Project: Email TextBox Control

🧲 Final Notes

Visual Basic .NET gives you full access to OOP principles, making your applications easier to maintain, debug, and extend. Whether you're validating inputs or building full-scale enterprise apps, OOP is the backbone of clean and professional VB.NET development.

🧼 Github Repo VB.NET-OOP

Clone/Contribute https://github.com/facebookegypt/VB.NET-OOP.git

 Here are some online Visual Basic lessons and courses:

Bottom Ad [Post Page]