The complete source code for a VB6 calculator is available on SourceCodester, demonstrating public variable declarations and event procedure implementations.
| Project Name | Description & Key Code Features | Best For | | :--- | :--- | :--- | | | A classic TxtCalculator project that demonstrates mathematical operations, variable type management ( Double / String ), and an intuitive UI. | Understanding core logic and UI event handling. | | Simple Grade Solver | A lightweight GradeSolver tool that processes input values to compute averages and letter grades, excellent for learning conditional logic. | Mastering If...Then...Else and arithmetic operations. | | StopWatch Application | An elegant StopWatch created with the Timer control, illustrating time-tracking logic and real-time interface updates. | Learning the Timer control and UI responsiveness. | | Text/Data Shuffler | An application to randomly shuffle data arrays, complete with tutorials and screenshots. Great for understanding randomization and data manipulation. | Array manipulation and random logic. |
: Uses timer controls and graphical API methods.
| Project Name | Description & Key Code Features | Best For | | :--- | :--- | :--- | | | A full MIS project including design documentation and complete source code. Supports full lifecycle warehouse control: inbound/outbound, stock query, alerts, and advanced reports. Uses ADO with SQL Server. | Enterprise-level system design and database scaling. | | VB6 to C# Migration Bridge | This ModernizationBridge shows how to integrate a legacy VB6 system with a modern C# API and PostgreSQL database, using HTTP calls from VB6 via MSXML. | Modernization strategies and hybrid architecture. | | FTP Server in VB6 | A full NokilonServer FTP server written entirely in VB6, supporting multiple connections, large file transfers, IPv6, and SQLite3 for the database. Stunningly powerful for a language like VB6. | Deep understanding of network protocols and sockets. | | Airline Reservation System | A full-featured booking app ( AirlineResSys ) with a database (MS Access), fully operational executable, and source files. Ideal for learning legacy UI controllers and travel workflows. | High-level logic of booking/reservation systems. |
' Exclusive VB6 CRUD Implementation Option Explicit Dim conn As ADODB.Connection Dim rs As ADODB.Recordset Dim connString As String Private Sub Form_Load() ' Define connection string to Microsoft Access Database connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CompanyDB.mdb;" Set conn = New ADODB.Connection Set rs = New ADODB.Recordset On Error GoTo ConnError conn.Open connString MsgBox "Successfully connected to the database!", vbInformation, "Connection Status" LoadData Exit Sub ConnError: MsgBox "Database connection failed: " & Err.Description, vbCritical, "Error" End Sub Private Sub LoadData() ' Refresh and load data into fields If rs.State = adStateOpen Then rs.Close rs.Open "SELECT * FROM Employees", conn, adOpenKeyset, adLockOptimistic If Not (rs.BOF And rs.EOF) Then rs.MoveFirst ShowRecord Else ClearFields MsgBox "No records found in the database.", vbExclamation, "Empty Database" End If End Sub Private Sub ShowRecord() ' Bind database fields to textboxes txtID.Text = rs.Fields("EmpID").Value txtName.Text = rs.Fields("EmpName").Value txtDesignation.Text = rs.Fields("Designation").Value txtSalary.Text = rs.Fields("Salary").Value End Sub Private Sub ClearFields() txtID.Text = "" txtName.Text = "" txtDesignation.Text = "" txtSalary.Text = "" End Sub Private Sub btnAdd_Click() ' Add a new record using SQL execution If txtName.Text = "" Or txtDesignation.Text = "" Or txtSalary.Text = "" Then MsgBox "Please fill in all fields.", vbExclamation, "Validation Error" Exit Sub End If Dim sql As String sql = "INSERT INTO Employees (EmpName, Designation, Salary) VALUES ('" & _ Replace(txtName.Text, "'", "''") & "', '" & _ Replace(txtDesignation.Text, "'", "''") & "', " & _ Val(txtSalary.Text) & ")" conn.Execute sql MsgBox "Employee record added successfully!", vbInformation, "Success" LoadData End Sub Private Sub btnUpdate_Click() ' Update an existing record If txtID.Text = "" Then Exit Sub Dim sql As String sql = "UPDATE Employees SET EmpName = '" & Replace(txtName.Text, "'", "''") & _ "', Designation = '" & Replace(txtDesignation.Text, "'", "''") & _ "', Salary = " & Val(txtSalary.Text) & _ " WHERE EmpID = " & Val(txtID.Text) conn.Execute sql MsgBox "Record updated successfully!", vbInformation, "Success" LoadData End Sub Private Sub btnDelete_Click() ' Delete a record safely If txtID.Text = "" Then Exit Sub Dim confirm As Integer confirm = MsgBox("Are you sure you want to delete this record?", vbYesNo + vbQuestion, "Confirm Delete") If confirm = vbYes Then Dim sql As String sql = "DELETE FROM Employees WHERE EmpID = " & Val(txtID.Text) conn.Execute sql MsgBox "Record deleted successfully.", vbInformation, "Deleted" LoadData End If End Sub Private Sub Form_Unload(Cancel As Integer) ' Clean up resources to prevent memory leaks On Error Resume Next If rs.State = adStateOpen Then rs.Close Set rs = Nothing If conn.State = adStateOpen Then conn.Close Set conn = Nothing End Sub Use code with caution.
txtOutput.Text = Result End Sub
Public Sub ProcessCheckout(ByVal CustomerID As Long, ByVal TotalAmount As Double, ByRef CartItems() As Variant) Dim conn As ADODB.Connection Dim cmd As ADODB.Command Dim i As Long Set conn = New ADODB.Connection conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database\inventory.mdb;" conn.Open ' Begin Transaction to guarantee atomicity conn.BeginTrans On Error GoTo TransactionError ' 1. Insert into Sales Master Dim salesID As Long Dim strSQL As String strSQL = "INSERT INTO tblSalesMaster (CustomerID, SaleDate, TotalAmount) VALUES (" & _ CustomerID & ", #" & Format(Now, "yyyy-mm-dd hh:nn:ss") & "#, " & TotalAmount & ")" conn.Execute strSQL ' Retrieve the auto-generated ID (Access specific method for current session) Dim rs As ADODB.Recordset Set rs = conn.Execute("SELECT @@IDENTITY") salesID = rs.Fields(0).Value rs.Close ' 2. Loop through array items to update stock and write sales details For i = LBound(CartItems) To UBound(CartItems) ' CartItems structure: 0=ProductID, 1=Qty, 2=UnitPrice ' Insert Detail strSQL = "INSERT INTO tblSalesDetails (SalesID, ProductID, Quantity, UnitPrice) VALUES (" & _ salesID & ", " & CartItems(i, 0) & ", " & CartItems(i, 1) & ", " & CartItems(i, 2) & ")" conn.Execute strSQL ' Deduct Inventory Stock strSQL = "UPDATE tblProducts SET StockLevel = StockLevel - " & CartItems(i, 1) & _ " WHERE ProductID = " & CartItems(i, 0) conn.Execute strSQL Next i ' Commit changes if all operations succeed conn.CommitTrans MsgBox "Transaction completed successfully!", vbInformation, "Success" CleanUp: Set rs = Nothing If conn.State = adStateOpen Then conn.Close Set conn = Nothing Exit Sub TransactionError: ' Rollback database state on failure conn.RollbackTrans MsgBox "Critical error during checkout. Changes reverted. Error: " & Err.Description, vbCritical, "Transaction Failed" Resume CleanUp End Sub Use code with caution. 2. Multi-Client Socket Chat Server & Client Project Overview
Private Sub Form_Load() With nid .cbSize = Len(nid) .hwnd = Me.hwnd .uID = vbNull .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE .uCallbackMessage = WM_MOUSEMOVE .hIcon = Me.Icon .szTip = "Exclusive VB6 App" & Chr$(0) End With Shell_NotifyIcon NIM_ADD, nid Me.Hide End Sub
' Save the log to the application folder fNum = FreeFile
' Code inside Form_Load of the Server Form Private Sub Form_Load() sckServer(0).LocalPort = 5001 sckServer(0).Listen List1.AddItem "Server started on port 5001. Awaiting connections..." End Sub ' Event triggered when a client attempts to connect Private Sub sckServer_ConnectionRequest(Index As Integer, ByVal requestID As Long) Dim nextIndex As Integer ' Only the listening socket (Index 0) should process incoming requests If Index = 0 Then nextIndex = FindFreeSocketSlot() ' Dynamically load a new control instance into the array Load sckServer(nextIndex) sckServer(nextIndex).Accept requestID List1.AddItem "Client connected from " & sckServer(nextIndex).RemoteHostIP & " on Slot #" & nextIndex BroadcastMessage "SYSTEM", "A new user has joined the room." End If End Sub ' Helper function to locate an idle socket or create a new slot Private Function FindFreeSocketSlot() As Integer Dim i As Integer For i = 1 To sckServer.UBound If sckServer(i).State = sckClosed Then FindFreeSocketSlot = i Exit Function End If Next i ' If no closed sockets exist, expand the array control limit FindFreeSocketSlot = sckServer.UBound + 1 End Function ' Event triggered when data arrives from any client Private Sub sckServer_DataArrival(Index As Integer, ByVal bytesTotal As Long) Dim strData As String sckServer(Index).GetData strData, vbString ' Parse protocol format: "USERNAME|MESSAGE" Dim parts() As String parts = Split(strData, "|") If UBound(parts) >= 1 Then List1.AddItem "[" & parts(0) & "]: " & parts(1) ' Relay data to all other active clients BroadcastMessage parts(0), parts(1) End If End Sub Private Sub BroadcastMessage(ByVal Sender As String, ByVal Msg As String) Dim i As Integer Dim packet As String packet = Sender & "|" & Msg For i = 1 To sckServer.UBound If sckServer(i).State = sckConnected Then sckServer(i).SendData packet DoEvents ' Yield execution to prevent network buffer congestion End If Next i End Sub Use code with caution. 3. Windows Win32 API Task Manager & Process Killer Project Overview
Option Explicit ' Win32 API Declarations Public Const TH32CS_SNAPPROCESS As Long = &H2 Public Const PROCESS_TERMINATE As Long = &H1 Public Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * 260 End Type Public Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long Public Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long Public Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long ' Populates a ListBox with current running processes Public Sub RefreshProcessList(lstTarget As ListBox) Dim hSnapshot As Long Dim pe32 As PROCESSENTRY32 Dim fSuccess As Long Dim exeName As String lstTarget.Clear pe32.dwSize = Len(pe32) hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) If hSnapshot = -1 Then Exit Sub fSuccess = Process32First(hSnapshot, pe32) Do While fSuccess ' Clean fixed-length string null characters exeName = Left$(pe32.szExeFile, InStr(pe32.szExeFile, Chr$(0)) - 1) ' Store process name along with its PID packed into the string item lstTarget.AddItem exeName & " (PID: " & pe32.th32ProcessID & ")" fSuccess = Process32Next(hSnapshot, pe32) Loop CloseHandle hSnapshot End Sub ' Forces a process shutdown by its Process Identifier (PID) Public Function KillProcessByPID(ByVal PID As Long) As Boolean Dim hProcess As Long Dim result As Long ' Request explicit termination rights from kernel hProcess = OpenProcess(PROCESS_TERMINATE, 0, PID) If hProcess <> 0 Then result = TerminateProcess(hProcess, 0) CloseHandle hProcess KillProcessByPID = (result <> 0) Else KillProcessByPID = False End If End Function Use code with caution. 4. Flat-File Cryptographic Text Editor (CipherPad) Project Overview
: A nearly perfect arcade replica using advanced techniques like the BltBit API for sprite animation and WAV file playback.
MASSAGE
SEND
×The message has been sent!
In the near future we will reply to you.
Regards WDS
|
The Dummy - a versatile design, the system of life and knowledge generated of nowhere. The story of the dummy requires a separate investigation and treatment of the ancient treatises, and primary sources. But enough evidence to suggest that the history of a WD the longer of Wing Chun history as an independent style. Will there be a dummy to before create a Wing Chun or Wing Chun has appeared before - difficult to resolve the problem, which requires special studies.
|
| SECTION 1 | ||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| SECTION 2 | ||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| SECTION 3 | ||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
||
| SECTION 4 | ||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| SECTION 5 | ||
![]() |
![]() ![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| SECTION 6 | ||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| SECTION 7 | ||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
| SECTION 8 | ||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
The complete source code for a VB6 calculator is available on SourceCodester, demonstrating public variable declarations and event procedure implementations.
| Project Name | Description & Key Code Features | Best For | | :--- | :--- | :--- | | | A classic TxtCalculator project that demonstrates mathematical operations, variable type management ( Double / String ), and an intuitive UI. | Understanding core logic and UI event handling. | | Simple Grade Solver | A lightweight GradeSolver tool that processes input values to compute averages and letter grades, excellent for learning conditional logic. | Mastering If...Then...Else and arithmetic operations. | | StopWatch Application | An elegant StopWatch created with the Timer control, illustrating time-tracking logic and real-time interface updates. | Learning the Timer control and UI responsiveness. | | Text/Data Shuffler | An application to randomly shuffle data arrays, complete with tutorials and screenshots. Great for understanding randomization and data manipulation. | Array manipulation and random logic. |
: Uses timer controls and graphical API methods.
| Project Name | Description & Key Code Features | Best For | | :--- | :--- | :--- | | | A full MIS project including design documentation and complete source code. Supports full lifecycle warehouse control: inbound/outbound, stock query, alerts, and advanced reports. Uses ADO with SQL Server. | Enterprise-level system design and database scaling. | | VB6 to C# Migration Bridge | This ModernizationBridge shows how to integrate a legacy VB6 system with a modern C# API and PostgreSQL database, using HTTP calls from VB6 via MSXML. | Modernization strategies and hybrid architecture. | | FTP Server in VB6 | A full NokilonServer FTP server written entirely in VB6, supporting multiple connections, large file transfers, IPv6, and SQLite3 for the database. Stunningly powerful for a language like VB6. | Deep understanding of network protocols and sockets. | | Airline Reservation System | A full-featured booking app ( AirlineResSys ) with a database (MS Access), fully operational executable, and source files. Ideal for learning legacy UI controllers and travel workflows. | High-level logic of booking/reservation systems. | visual basic 60 projects with source code exclusive
' Exclusive VB6 CRUD Implementation Option Explicit Dim conn As ADODB.Connection Dim rs As ADODB.Recordset Dim connString As String Private Sub Form_Load() ' Define connection string to Microsoft Access Database connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CompanyDB.mdb;" Set conn = New ADODB.Connection Set rs = New ADODB.Recordset On Error GoTo ConnError conn.Open connString MsgBox "Successfully connected to the database!", vbInformation, "Connection Status" LoadData Exit Sub ConnError: MsgBox "Database connection failed: " & Err.Description, vbCritical, "Error" End Sub Private Sub LoadData() ' Refresh and load data into fields If rs.State = adStateOpen Then rs.Close rs.Open "SELECT * FROM Employees", conn, adOpenKeyset, adLockOptimistic If Not (rs.BOF And rs.EOF) Then rs.MoveFirst ShowRecord Else ClearFields MsgBox "No records found in the database.", vbExclamation, "Empty Database" End If End Sub Private Sub ShowRecord() ' Bind database fields to textboxes txtID.Text = rs.Fields("EmpID").Value txtName.Text = rs.Fields("EmpName").Value txtDesignation.Text = rs.Fields("Designation").Value txtSalary.Text = rs.Fields("Salary").Value End Sub Private Sub ClearFields() txtID.Text = "" txtName.Text = "" txtDesignation.Text = "" txtSalary.Text = "" End Sub Private Sub btnAdd_Click() ' Add a new record using SQL execution If txtName.Text = "" Or txtDesignation.Text = "" Or txtSalary.Text = "" Then MsgBox "Please fill in all fields.", vbExclamation, "Validation Error" Exit Sub End If Dim sql As String sql = "INSERT INTO Employees (EmpName, Designation, Salary) VALUES ('" & _ Replace(txtName.Text, "'", "''") & "', '" & _ Replace(txtDesignation.Text, "'", "''") & "', " & _ Val(txtSalary.Text) & ")" conn.Execute sql MsgBox "Employee record added successfully!", vbInformation, "Success" LoadData End Sub Private Sub btnUpdate_Click() ' Update an existing record If txtID.Text = "" Then Exit Sub Dim sql As String sql = "UPDATE Employees SET EmpName = '" & Replace(txtName.Text, "'", "''") & _ "', Designation = '" & Replace(txtDesignation.Text, "'", "''") & _ "', Salary = " & Val(txtSalary.Text) & _ " WHERE EmpID = " & Val(txtID.Text) conn.Execute sql MsgBox "Record updated successfully!", vbInformation, "Success" LoadData End Sub Private Sub btnDelete_Click() ' Delete a record safely If txtID.Text = "" Then Exit Sub Dim confirm As Integer confirm = MsgBox("Are you sure you want to delete this record?", vbYesNo + vbQuestion, "Confirm Delete") If confirm = vbYes Then Dim sql As String sql = "DELETE FROM Employees WHERE EmpID = " & Val(txtID.Text) conn.Execute sql MsgBox "Record deleted successfully.", vbInformation, "Deleted" LoadData End If End Sub Private Sub Form_Unload(Cancel As Integer) ' Clean up resources to prevent memory leaks On Error Resume Next If rs.State = adStateOpen Then rs.Close Set rs = Nothing If conn.State = adStateOpen Then conn.Close Set conn = Nothing End Sub Use code with caution.
txtOutput.Text = Result End Sub
Public Sub ProcessCheckout(ByVal CustomerID As Long, ByVal TotalAmount As Double, ByRef CartItems() As Variant) Dim conn As ADODB.Connection Dim cmd As ADODB.Command Dim i As Long Set conn = New ADODB.Connection conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\database\inventory.mdb;" conn.Open ' Begin Transaction to guarantee atomicity conn.BeginTrans On Error GoTo TransactionError ' 1. Insert into Sales Master Dim salesID As Long Dim strSQL As String strSQL = "INSERT INTO tblSalesMaster (CustomerID, SaleDate, TotalAmount) VALUES (" & _ CustomerID & ", #" & Format(Now, "yyyy-mm-dd hh:nn:ss") & "#, " & TotalAmount & ")" conn.Execute strSQL ' Retrieve the auto-generated ID (Access specific method for current session) Dim rs As ADODB.Recordset Set rs = conn.Execute("SELECT @@IDENTITY") salesID = rs.Fields(0).Value rs.Close ' 2. Loop through array items to update stock and write sales details For i = LBound(CartItems) To UBound(CartItems) ' CartItems structure: 0=ProductID, 1=Qty, 2=UnitPrice ' Insert Detail strSQL = "INSERT INTO tblSalesDetails (SalesID, ProductID, Quantity, UnitPrice) VALUES (" & _ salesID & ", " & CartItems(i, 0) & ", " & CartItems(i, 1) & ", " & CartItems(i, 2) & ")" conn.Execute strSQL ' Deduct Inventory Stock strSQL = "UPDATE tblProducts SET StockLevel = StockLevel - " & CartItems(i, 1) & _ " WHERE ProductID = " & CartItems(i, 0) conn.Execute strSQL Next i ' Commit changes if all operations succeed conn.CommitTrans MsgBox "Transaction completed successfully!", vbInformation, "Success" CleanUp: Set rs = Nothing If conn.State = adStateOpen Then conn.Close Set conn = Nothing Exit Sub TransactionError: ' Rollback database state on failure conn.RollbackTrans MsgBox "Critical error during checkout. Changes reverted. Error: " & Err.Description, vbCritical, "Transaction Failed" Resume CleanUp End Sub Use code with caution. 2. Multi-Client Socket Chat Server & Client Project Overview The complete source code for a VB6 calculator
Private Sub Form_Load() With nid .cbSize = Len(nid) .hwnd = Me.hwnd .uID = vbNull .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE .uCallbackMessage = WM_MOUSEMOVE .hIcon = Me.Icon .szTip = "Exclusive VB6 App" & Chr$(0) End With Shell_NotifyIcon NIM_ADD, nid Me.Hide End Sub
' Save the log to the application folder fNum = FreeFile
' Code inside Form_Load of the Server Form Private Sub Form_Load() sckServer(0).LocalPort = 5001 sckServer(0).Listen List1.AddItem "Server started on port 5001. Awaiting connections..." End Sub ' Event triggered when a client attempts to connect Private Sub sckServer_ConnectionRequest(Index As Integer, ByVal requestID As Long) Dim nextIndex As Integer ' Only the listening socket (Index 0) should process incoming requests If Index = 0 Then nextIndex = FindFreeSocketSlot() ' Dynamically load a new control instance into the array Load sckServer(nextIndex) sckServer(nextIndex).Accept requestID List1.AddItem "Client connected from " & sckServer(nextIndex).RemoteHostIP & " on Slot #" & nextIndex BroadcastMessage "SYSTEM", "A new user has joined the room." End If End Sub ' Helper function to locate an idle socket or create a new slot Private Function FindFreeSocketSlot() As Integer Dim i As Integer For i = 1 To sckServer.UBound If sckServer(i).State = sckClosed Then FindFreeSocketSlot = i Exit Function End If Next i ' If no closed sockets exist, expand the array control limit FindFreeSocketSlot = sckServer.UBound + 1 End Function ' Event triggered when data arrives from any client Private Sub sckServer_DataArrival(Index As Integer, ByVal bytesTotal As Long) Dim strData As String sckServer(Index).GetData strData, vbString ' Parse protocol format: "USERNAME|MESSAGE" Dim parts() As String parts = Split(strData, "|") If UBound(parts) >= 1 Then List1.AddItem "[" & parts(0) & "]: " & parts(1) ' Relay data to all other active clients BroadcastMessage parts(0), parts(1) End If End Sub Private Sub BroadcastMessage(ByVal Sender As String, ByVal Msg As String) Dim i As Integer Dim packet As String packet = Sender & "|" & Msg For i = 1 To sckServer.UBound If sckServer(i).State = sckConnected Then sckServer(i).SendData packet DoEvents ' Yield execution to prevent network buffer congestion End If Next i End Sub Use code with caution. 3. Windows Win32 API Task Manager & Process Killer Project Overview | | Simple Grade Solver | A lightweight
Option Explicit ' Win32 API Declarations Public Const TH32CS_SNAPPROCESS As Long = &H2 Public Const PROCESS_TERMINATE As Long = &H1 Public Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * 260 End Type Public Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long Public Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long Public Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long ' Populates a ListBox with current running processes Public Sub RefreshProcessList(lstTarget As ListBox) Dim hSnapshot As Long Dim pe32 As PROCESSENTRY32 Dim fSuccess As Long Dim exeName As String lstTarget.Clear pe32.dwSize = Len(pe32) hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) If hSnapshot = -1 Then Exit Sub fSuccess = Process32First(hSnapshot, pe32) Do While fSuccess ' Clean fixed-length string null characters exeName = Left$(pe32.szExeFile, InStr(pe32.szExeFile, Chr$(0)) - 1) ' Store process name along with its PID packed into the string item lstTarget.AddItem exeName & " (PID: " & pe32.th32ProcessID & ")" fSuccess = Process32Next(hSnapshot, pe32) Loop CloseHandle hSnapshot End Sub ' Forces a process shutdown by its Process Identifier (PID) Public Function KillProcessByPID(ByVal PID As Long) As Boolean Dim hProcess As Long Dim result As Long ' Request explicit termination rights from kernel hProcess = OpenProcess(PROCESS_TERMINATE, 0, PID) If hProcess <> 0 Then result = TerminateProcess(hProcess, 0) CloseHandle hProcess KillProcessByPID = (result <> 0) Else KillProcessByPID = False End If End Function Use code with caution. 4. Flat-File Cryptographic Text Editor (CipherPad) Project Overview
: A nearly perfect arcade replica using advanced techniques like the BltBit API for sprite animation and WAV file playback.