Visual Basic Projects With Source Code File

Private Sub SaveTasks() Using writer As New StreamWriter(tasksFile) For Each task In lstTasks.Items writer.WriteLine(task.ToString()) Next End Using End Sub

If board(row, col) = "" AndAlso gameActive AndAlso currentPlayer = "X" Then MakeMove(row, col, "X") If gameActive Then currentPlayer = "O" lblStatus.Text = "Computer's turn..." ComputerMove() currentPlayer = "X" End If End If End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' Load tasks from file on startup If File.Exists(tasksFile) Then Dim lines() As String = File.ReadAllLines(tasksFile) For Each line In lines lstTasks.Items.Add(line) Next End If End Sub

Let me know in the comments which project you plan to build first, or share your own VB project ideas below! Happy coding! 🚀 visual basic projects with source code

Imports System.IO Public Class ImageViewer Private imageFiles As String() = Nothing Private currentIndex As Integer = 0

If CheckWin(player) Then lblStatus.Text = $"{player} wins!" gameActive = False ElseIf IsDraw() Then lblStatus.Text = "Draw!" gameActive = False End If End Sub

Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click If txtTask.Text.Trim() <> "" Then lstTasks.Items.Add(txtTask.Text) txtTask.Clear() SaveTasks() End If End Sub In the enterprise world, VB

Private Function CheckWin(player As String) As Boolean ' Check rows, columns, diagonals For i = 0 To 2 If board(i, 0) = player AndAlso board(i, 1) = player AndAlso board(i, 2) = player Then Return True If board(0, i) = player AndAlso board(1, i) = player AndAlso board(2, i) = player Then Return True Next If board(0, 0) = player AndAlso board(1, 1) = player AndAlso board(2, 2) = player Then Return True If board(0, 2) = player AndAlso board(1, 1) = player AndAlso board(2, 0) = player Then Return True Return False End Function

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load conn = New SQLiteConnection(connectionString) conn.Open() ' Create table if not exists Dim cmd As New SQLiteCommand("CREATE TABLE IF NOT EXISTS Students (ID INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, Grade INTEGER)", conn) cmd.ExecuteNonQuery() LoadData() End Sub

Visual Basic (VB.NET) often gets a bad rap as a "beginner's toy," but don't let the critics fool you. In the enterprise world, VB.NET is a fully supported, object-oriented language that runs on the powerful .NET framework. It is incredibly efficient for building Windows desktop applications (WinForms), automating Excel, and even creating web apps. In the enterprise world

Imports System.IO Public Class TodoApp Private tasksFile As String = "tasks.txt"

Private Sub ComputerMove() If Not gameActive Then Exit Sub Dim emptyCells As New List(Of Tuple(Of Integer, Integer)) For i = 0 To 2 For j = 0 To 2 If board(i, j) = "" Then emptyCells.Add(Tuple.Create(i, j)) Next Next