Visual Basic Projects With Source Code -
Private Sub LoadData() Dim adapter As New SQLiteDataAdapter("SELECT * FROM Students", conn) Dim table As New DataTable() adapter.Fill(table) DataGridView1.DataSource = table 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 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
If emptyCells.Count > 0 Then Dim rnd As New Random() Dim move = emptyCells(rnd.Next(emptyCells.Count)) MakeMove(move.Item1, move.Item2, "O") End If End Sub visual basic projects with source code
Private Sub MakeMove(row As Integer, col As Integer, player As String) board(row, col) = player Dim btn As Button = GetButton(row, col) btn.Text = player btn.Enabled = False
Select Case operation Case "+" : result = firstNumber + secondNumber Case "-" : result = firstNumber - secondNumber Case "*" : result = firstNumber * secondNumber Case "/" : result = firstNumber / secondNumber End Select
Private Sub btnEquals_Click(sender As Object, e As EventArgs) Handles btnEquals.Click Dim secondNumber As Double = Double.Parse(currentInput) Dim result As Double = 0 If CheckWin(player) Then lblStatus
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.
If CheckWin(player) Then lblStatus.Text = $"{player} wins!" gameActive = False ElseIf IsDraw() Then lblStatus.Text = "Draw!" gameActive = False End If End Sub
Public Class TicTacToe Dim board(2, 2) As String ' "X", "O", or "" Dim currentPlayer As String = "X" Dim gameActive As Boolean = True Private Sub Button_Click(sender As Object, e As EventArgs) Handles btn00.Click, btn01.Click, btn02.Click, btn10.Click, btn11.Click, btn12.Click, btn20.Click, btn21.Click, btn22.Click Dim btn As Button = CType(sender, Button) Dim row As Integer = CInt(btn.Tag.ToString().Substring(0, 1)) Dim col As Integer = CInt(btn.Tag.ToString().Substring(1, 1)) 🚀 txtDisplay
Public Class Calculator Dim currentInput As String = "" Dim firstNumber As Double = 0 Dim operation As String = "" Private Sub Number_Click(sender As Object, e As EventArgs) Handles Button1.Click, Button2.Click, '... etc Dim btn As Button = CType(sender, Button) currentInput &= btn.Text txtDisplay.Text = currentInput End Sub
Private Sub btnLoad_Click(sender As Object, e As EventArgs) Handles btnLoad.Click Using folderDialog As New FolderBrowserDialog() If folderDialog.ShowDialog() = DialogResult.OK Then imageFiles = Directory.GetFiles(folderDialog.SelectedPath, "*.*") .Where(Function(f) f.ToLower().EndsWith(".jpg") OrElse f.ToLower().EndsWith(".png") OrElse f.ToLower().EndsWith(".bmp")) .ToArray() currentIndex = 0 ShowImage() End If End Using 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! 🚀
txtDisplay.Text = result.ToString() currentInput = result.ToString() End Sub
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click Dim cmd As New SQLiteCommand("INSERT INTO Students (Name, Grade) VALUES (@name, @grade)", conn) cmd.Parameters.AddWithValue("@name", txtName.Text) cmd.Parameters.AddWithValue("@grade", CInt(txtGrade.Text)) cmd.ExecuteNonQuery() LoadData() CalculateAverage() End Sub