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 SaveTasks() Using writer As New StreamWriter(tasksFile) For Each task In lstTasks.Items writer.WriteLine(task.ToString()) Next End Using End Sub visual basic projects with source code
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 Private Function CheckWin(player As String) As Boolean '
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. Private Sub ShowImage() If imageFiles IsNot Nothing AndAlso
Private Sub ShowImage() If imageFiles IsNot Nothing AndAlso imageFiles.Length > 0 Then picImage.Image = Image.FromFile(imageFiles(currentIndex)) Me.Text = $"Image Viewer - {Path.GetFileName(imageFiles(currentIndex))}" End If End Sub
If CheckWin(player) Then lblStatus.Text = $"{player} wins!" gameActive = False ElseIf IsDraw() Then lblStatus.Text = "Draw!" gameActive = False End If End Sub
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click If lstTasks.SelectedItem IsNot Nothing Then lstTasks.Items.Remove(lstTasks.SelectedItem) SaveTasks() End If End Sub