├── ErrorHandling.vb ├── ErrorrH.vb ├── GradingSystemApplication.vb ├── ProFun.vb ├── README.md ├── ShoppingListApplication.vb ├── dataEntryForm.vb ├── digitalRecords.vb ├── example1.vb ├── example2.vb ├── example3.vb ├── example4.vb ├── example5.vb ├── exampleFive.vb ├── exampleFour.vb ├── exampleOne.vb ├── exampleThree.vb ├── exampleTwo.vb ├── gradingSystem.vb ├── loginForm.vb ├── operators.vb ├── paymentSystem.vb ├── receiptForm.vb └── umemeForecast.vb /ErrorHandling.vb: -------------------------------------------------------------------------------- 1 | Sub DivisionExample() 2 | Try 3 | Console.Write("Enter first number: ") 4 | Dim num1 As Integer = Convert.ToInt32(Console.ReadLine()) 5 | Console.Write("Enter second number: ") 6 | Dim num2 As Integer = Convert.ToInt32(Console.ReadLine()) 7 | 8 | Dim result As Integer = num1 / num2 9 | Console.WriteLine("Result: " & result) 10 | Catch ex As DivideByZeroException 11 | Console.WriteLine("Error: Division by zero is not allowed.") 12 | Catch ex As FormatException 13 | Console.WriteLine("Error: Please enter a valid integer.") 14 | Finally 15 | Console.WriteLine("Program complete.") 16 | End Try 17 | End Sub 18 | -------------------------------------------------------------------------------- /ErrorrH.vb: -------------------------------------------------------------------------------- 1 | Sub DivideNumbers() 2 | Try 3 | Dim num1 As Integer = 10 4 | Dim num2 As Integer = 0 5 | Dim result As Integer = num1 / num2 6 | Console.WriteLine("Result: " & result) 7 | Catch ex As DivideByZeroException 8 | Console.WriteLine("Error: Division by zero is not allowed.") 9 | Finally 10 | Console.WriteLine("Operation completed.") 11 | End Try 12 | End Sub 13 | -------------------------------------------------------------------------------- /GradingSystemApplication.vb: -------------------------------------------------------------------------------- 1 | ' Grading System Application 2 | ' Created for NCIT221-1 Practical Exam 3 | ' Student Name: [Your Name] 4 | ' Registration Number: [Your Reg No] 5 | 6 | Public Class GradingForm 7 | ' Event handler for Grade button 8 | Private Sub btnGrade_Click(sender As Object, e As EventArgs) Handles btnGrade.Click 9 | ' Declare variables 10 | Dim mark As Double 11 | Dim gpa As Double 12 | 13 | ' Validate input is numeric 14 | If Not Double.TryParse(txtMark.Text, mark) Then 15 | MessageBox.Show("Please enter a valid numeric mark", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning) 16 | Return 17 | End If 18 | 19 | ' Validate mark is within 0-100 range 20 | If mark < 0 Or mark > 100 Then 21 | MessageBox.Show("Mark must be between 0 and 100", "Invalid Range", MessageBoxButtons.OK, MessageBoxIcon.Warning) 22 | Return 23 | End If 24 | 25 | ' Determine GPA based on mark range 26 | If mark >= 80 Then 27 | gpa = 5.0 28 | ElseIf mark >= 75 Then 29 | gpa = 4.5 30 | ElseIf mark >= 70 Then 31 | gpa = 4.0 32 | ElseIf mark >= 65 Then 33 | gpa = 3.6 34 | ElseIf mark >= 60 Then 35 | gpa = 3.0 36 | ElseIf mark >= 55 Then 37 | gpa = 2.5 38 | ElseIf mark >= 50 Then 39 | gpa = 2.0 40 | Else 41 | gpa = 0.0 ' For marks below 50 (fail) 42 | End If 43 | 44 | ' Display the GPA 45 | lblGPA.Text = "GPA: " & gpa.ToString("0.0") 46 | End Sub 47 | 48 | ' Event handler for Award button 49 | Private Sub btnAward_Click(sender As Object, e As EventArgs) Handles btnAward.Click 50 | ' Declare variables 51 | Dim mark As Double 52 | Dim award As String 53 | 54 | ' Validate input is numeric 55 | If Not Double.TryParse(txtMark.Text, mark) Then 56 | MessageBox.Show("Please enter a valid numeric mark", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Warning) 57 | Return 58 | End If 59 | 60 | ' Validate mark is within 0-100 range 61 | If mark < 0 Or mark > 100 Then 62 | MessageBox.Show("Mark must be between 0 and 100", "Invalid Range", MessageBoxButtons.OK, MessageBoxIcon.Warning) 63 | Return 64 | End If 65 | 66 | ' Determine degree award based on mark range 67 | If mark >= 75 Then 68 | award = "First Class Honors" 69 | ElseIf mark >= 65 Then 70 | award = "Second Class Upper" 71 | ElseIf mark >= 55 Then 72 | award = "Second Class Lower" 73 | ElseIf mark >= 50 Then 74 | award = "Pass Degree" 75 | Else 76 | award = "Fail - No Degree Awarded" 77 | End If 78 | 79 | ' Display the award 80 | lblAward.Text = "Degree Awarded: " & award 81 | End Sub 82 | 83 | ' Event handler for Reset button 84 | Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click 85 | ' Reset all fields to default values 86 | txtMark.Text = "" 87 | lblGPA.Text = "GPA: " 88 | lblAward.Text = "Degree Awarded: " 89 | 90 | ' Set focus back to mark textbox 91 | txtMark.Focus() 92 | End Sub 93 | End Class -------------------------------------------------------------------------------- /ProFun.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | Module Program 4 | Sub Main(args As String()) 5 | Console.WriteLine("ICT211, Loves VB") 6 | End Sub 7 | End Module -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Dear ICT 211, Pragramming for Business Application 2 | The Test Link is here. 3 | https://forms.gle/kbYTjuPyQPwywvgm6 4 | 5 | Time: 3:00 to 4:00pm 6 | 7 | Good Luck 8 | 9 | 10 | 11 | 12 | Step for cloning 13 | 1. git clone https://github.com/drjeffgeoff/VisualBasic.git 14 | -------------------------------------------------------------------------------- /ShoppingListApplication.vb: -------------------------------------------------------------------------------- 1 | ' Shopping List Application 2 | ' Created for NCIT221-1 Practical Exam 3 | ' Student Name: [Your Name] 4 | ' Registration Number: [Your Reg No] 5 | 6 | Public Class ShoppingListForm 7 | 8 | ' Event handler for Add Item button 9 | Private Sub btnAddItem_Click(sender As Object, e As EventArgs) Handles btnAddItem.Click 10 | ' Check if the textbox is not empty 11 | If txtAddItem.Text <> "" Then 12 | ' Add the item from textbox to the listbox 13 | lstShopping.Items.Add(txtAddItem.Text) 14 | ' Clear the textbox for next entry 15 | txtAddItem.Text = "" 16 | ' Set focus back to textbox for convenience 17 | txtAddItem.Focus() 18 | Else 19 | ' Show message if textbox is empty 20 | MessageBox.Show("Please enter an item to add", "Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Warning) 21 | End If 22 | End Sub 23 | 24 | ' Event handler for Save Shopping List button 25 | Private Sub btnSaveList_Click(sender As Object, e As EventArgs) Handles btnSaveList.Click 26 | ' Check if there are items in the listbox 27 | If lstShopping.Items.Count > 0 Then 28 | ' Configure the save file dialog 29 | saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" 30 | saveFileDialog.Title = "Save Shopping List" 31 | saveFileDialog.DefaultExt = "txt" 32 | 33 | ' Show the save file dialog 34 | If saveFileDialog.ShowDialog() = DialogResult.OK Then 35 | Try 36 | ' Create a StreamWriter to write to the file 37 | Dim writer As New System.IO.StreamWriter(saveFileDialog.FileName) 38 | 39 | ' Write each item from the listbox to the file 40 | For Each item In lstShopping.Items 41 | writer.WriteLine(item.ToString()) 42 | Next 43 | 44 | ' Close the writer 45 | writer.Close() 46 | 47 | ' Show success message 48 | MessageBox.Show("Shopping list saved successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information) 49 | Catch ex As Exception 50 | ' Show error message if saving fails 51 | MessageBox.Show("Error saving file: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) 52 | End Try 53 | End If 54 | Else 55 | ' Show message if listbox is empty 56 | MessageBox.Show("There are no items in the shopping list to save", "Empty List", MessageBoxButtons.OK, MessageBoxIcon.Warning) 57 | End If 58 | End Sub 59 | End Class -------------------------------------------------------------------------------- /dataEntryForm.vb: -------------------------------------------------------------------------------- 1 | Public Class dataEntryForm 2 | ' Variables to store data 3 | Public Shared customerName As String 4 | Public Shared itemName As String 5 | Public Shared quantity As Integer 6 | Public Shared pricePerItem As Decimal 7 | Public Shared servedBy As String 8 | Public Shared dateOfPurchase As Date 9 | 10 | Private Sub btnGenerateReceipt_Click(sender As Object, e As EventArgs) Handles btnGenerateReceipt.Click 11 | ' Capture input data 12 | customerName = txtCustomerName.Text 13 | itemName = txtItemName.Text 14 | quantity = Integer.Parse(txtQuantity.Text) 15 | pricePerItem = Decimal.Parse(txtPricePerItem.Text) 16 | servedBy = txtServedBy.Text 17 | dateOfPurchase = dtpDateOfPurchase.Value 18 | 19 | ' Open the Receipt Form to display the generated receipt 20 | Dim receiptForm As New ReceiptForm 21 | receiptForm.Show() 22 | Me.Hide() 23 | End Sub 24 | End Class 25 | -------------------------------------------------------------------------------- /digitalRecords.vb: -------------------------------------------------------------------------------- 1 | Public Class digitalRecords 2 | Private Sub btnGenerateSummary_Click(sender As Object, e As EventArgs) Handles btnGenerateSummary.Click 3 | ' Capture the input values 4 | Dim invoiceNumber As String = txtInvoiceNumber.Text 5 | Dim dateInvoice As String = txtDateInvoice.Text 6 | Dim passenger As String = txtPassenger.Text 7 | Dim destination As String = txtDestination.Text 8 | Dim transportCost As String = txtTransportCost.Text 9 | 10 | ' Concatenate the input values into a summary string 11 | Dim summary As String = "Invoice Number: " & invoiceNumber & vbCrLf & 12 | "Date Invoice: " & dateInvoice & vbCrLf & 13 | "Passenger: " & passenger & vbCrLf & 14 | "Destination: " & destination & vbCrLf & 15 | "Transport Cost: " & transportCost 16 | 17 | ' Display the summary in the Summary textbox 18 | txtSummary.Text = summary 19 | End Sub 20 | End Class -------------------------------------------------------------------------------- /example1.vb: -------------------------------------------------------------------------------- 1 | Sub DisplayMessage() 2 | Console.WriteLine("Welcome to Visual Basic programming!") 3 | End Sub 4 | 5 | Sub Main() 6 | DisplayMessage() ' Call the Sub Procedure 7 | End Sub 8 | -------------------------------------------------------------------------------- /example2.vb: -------------------------------------------------------------------------------- 1 | Sub GreetUser(ByVal name As String) 2 | Console.WriteLine("Hello, " & name & "!") 3 | End Sub 4 | 5 | Sub Main() 6 | GreetUser("Jeff Geoff") ' Call the Sub Procedure with an argument 7 | End Sub 8 | -------------------------------------------------------------------------------- /example3.vb: -------------------------------------------------------------------------------- 1 | Function AddNumbers(ByVal num1 As Integer, ByVal num2 As Integer) As Integer 2 | Return num1 + num2 3 | End Function 4 | 5 | Sub Main() 6 | Dim result As Integer = AddNumbers(5, 10) ' Call the function and store the result 7 | Console.WriteLine("Sum: " & result) 8 | End Sub 9 | -------------------------------------------------------------------------------- /example4.vb: -------------------------------------------------------------------------------- 1 | Sub ModifyByVal(ByVal x As Integer) 2 | x += 10 ' This will not affect the original variable 3 | End Sub 4 | 5 | Sub ModifyByRef(ByRef x As Integer) 6 | x += 10 ' This will modify the original variable 7 | End Sub 8 | 9 | Sub Main() 10 | Dim number As Integer = 20 11 | 12 | ModifyByVal(number) 13 | Console.WriteLine("After ByVal: " & number) ' Output: 20 (no change) 14 | 15 | ModifyByRef(number) 16 | Console.WriteLine("After ByRef: " & number) ' Output: 30 (modified) 17 | End Sub 18 | -------------------------------------------------------------------------------- /example5.vb: -------------------------------------------------------------------------------- 1 | Sub CounterExample() 2 | Static count As Integer = 0 ' Static variable 3 | Dim localCount As Integer = 0 ' Local variable 4 | 5 | count += 1 6 | localCount += 1 7 | 8 | Console.WriteLine("Static count: " & count) 9 | Console.WriteLine("Local count: " & localCount) 10 | End Sub 11 | 12 | Sub Main() 13 | CounterExample() ' First call 14 | CounterExample() ' Second call 15 | CounterExample() ' Third call 16 | End Sub 17 | -------------------------------------------------------------------------------- /exampleFive.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | 'Select Case Control Structure 4 | 5 | Module ExampleFive 6 | Sub Main() 7 | Dim dayNumber As Integer 8 | 9 | ' Input day number 10 | Console.WriteLine("Enter a number (1 to 7) to get the day of the week:") 11 | dayNumber = Convert.ToInt32(Console.ReadLine()) 12 | 13 | ' Select Case structure 14 | Select Case dayNumber 15 | Case 1 16 | Console.WriteLine("Sunday") 17 | Case 2 18 | Console.WriteLine("Monday") 19 | Case 3 20 | Console.WriteLine("Tuesday") 21 | Case 4 22 | Console.WriteLine("Wednesday") 23 | Case 5 24 | Console.WriteLine("Thursday") 25 | Case 6 26 | Console.WriteLine("Friday") 27 | Case 7 28 | Console.WriteLine("Saturday") 29 | Case Else 30 | Console.WriteLine("Invalid input!") 31 | End Select 32 | 33 | Console.ReadLine() 34 | End Sub 35 | End Module 36 | 37 | -------------------------------------------------------------------------------- /exampleFour.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | 'Looping with While Loop 4 | 5 | Module ExampleFour 6 | Sub Main() 7 | Dim number As Integer = 0 8 | 9 | ' While loop 10 | While number >= 0 11 | Console.WriteLine("Enter a number (negative to stop):") 12 | number = Convert.ToInt32(Console.ReadLine()) 13 | 14 | If number >= 0 Then 15 | Console.WriteLine("You entered: " & number) 16 | End If 17 | End While 18 | 19 | Console.WriteLine("Loop ended due to negative input.") 20 | Console.ReadLine() 21 | End Sub 22 | End Module 23 | -------------------------------------------------------------------------------- /exampleOne.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | 'Declaring and Initializing Variables 4 | 5 | Module exampleOne 6 | Sub Main() 7 | ' Declaring variables 8 | Dim name As String = "Mwajjuma" 9 | Dim age As Integer = 30 10 | Dim salary As Double = 4500.50 11 | Dim isActive As Boolean = True 12 | 13 | ' Displaying the variables 14 | Console.WriteLine("Name: " & name) 15 | Console.WriteLine("Age: " & age) 16 | Console.WriteLine("Salary: " & salary) 17 | Console.WriteLine("Active Employee: " & isActive) 18 | 19 | Console.ReadLine() ' To keep the console open 20 | End Sub 21 | End Module 22 | -------------------------------------------------------------------------------- /exampleThree.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drjeffgeoff/VisualBasic/ab1c070ca357387fed2b3724145e33e5712d642c/exampleThree.vb -------------------------------------------------------------------------------- /exampleTwo.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | 3 | 'Conditional Statement (If...Then...Else) 4 | 5 | Module ExampleTwo 6 | Sub Main() 7 | Dim number As Integer 8 | 9 | ' Input number 10 | Console.WriteLine("Enter a number:") 11 | number = Convert.ToInt32(Console.ReadLine()) 12 | 13 | ' Conditional check 14 | If number > 0 Then 15 | Console.WriteLine("The number is positive.") 16 | ElseIf number < 0 Then 17 | Console.WriteLine("The number is negative.") 18 | Else 19 | Console.WriteLine("The number is zero.") 20 | End If 21 | 22 | Console.ReadLine() 23 | End Sub 24 | End Module 25 | -------------------------------------------------------------------------------- /gradingSystem.vb: -------------------------------------------------------------------------------- 1 | Public Class gradingSystem 2 | 3 | Private Sub btnEvaluate_Click(sender As Object, e As EventArgs) Handles btnEvaluate.Click 4 | Dim marks As Integer 5 | 6 | ' Input validation for marks to ensure numeric input 7 | If Not Integer.TryParse(txtMarks.Text, marks) Then 8 | MessageBox.Show("Please enter a valid numeric value for marks.") 9 | Exit Sub 10 | End If 11 | 12 | ' Check if marks exceed 100 13 | If marks > 100 Then 14 | MessageBox.Show("Wrong entry, please re-enter the mark") 15 | Exit Sub 16 | End If 17 | 18 | ' Using Select Case to determine the grade based on marks 19 | Select Case marks 20 | Case 90 To 100 21 | lblGrade.Text = "Excellent" 22 | Case 80 To 89 23 | lblGrade.Text = "Very Good" 24 | Case 70 To 79 25 | lblGrade.Text = "Good" 26 | Case 60 To 69 27 | lblGrade.Text = "Medium" 28 | Case 50 To 59 29 | lblGrade.Text = "Pass" 30 | Case 0 To 49 31 | lblGrade.Text = "Fail" 32 | Case Else 33 | lblGrade.Text = "Invalid Marks" 34 | End Select 35 | End Sub 36 | End Class -------------------------------------------------------------------------------- /loginForm.vb: -------------------------------------------------------------------------------- 1 | Public Class loginForm 2 | Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click 3 | ' Hardcoded username and password 4 | If txtUsername.Text = "admin" And txtPassword.Text = "password" Then 5 | ' Open the Data Entry Form if login is successful 6 | Dim dataEntryForm As New DataEntryForm 7 | dataEntryForm.Show() 8 | Me.Hide() ' Hide the Login Form 9 | Else 10 | MessageBox.Show("Invalid Username or Password", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error) 11 | End If 12 | End Sub 13 | End Class 14 | -------------------------------------------------------------------------------- /operators.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/drjeffgeoff/VisualBasic/ab1c070ca357387fed2b3724145e33e5712d642c/operators.vb -------------------------------------------------------------------------------- /paymentSystem.vb: -------------------------------------------------------------------------------- 1 | ' Code for Button for Login 2 | Public Class paymentSystem 3 | Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click 4 | ' Check if the username is "Accounts" and password is "pass123" 5 | If txtUsername.Text = "Accounts" And txtPassword.Text = "pass123" Then 6 | ' Navigate to the second form (dataform) if successful 7 | Dim dataForm As New dataform() 8 | dataForm.Show() 9 | Me.Hide() ' Hide the login form 10 | Else 11 | ' Display message box for incorrect credentials 12 | MessageBox.Show("Incorrect username/password") 13 | End If 14 | End Sub 15 | 16 | End Class 17 | 18 | 19 | ' Code for DataForm 20 | Public Class dataform 21 | Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click 22 | ' Input validation for numeric fields 23 | Dim basicPay As Decimal 24 | Dim medicalAllowance As Decimal 25 | If Not Decimal.TryParse(txtBasicPay.Text, basicPay) Or Not Decimal.TryParse(txtMedicalAllowance.Text, medicalAllowance) Then 26 | MessageBox.Show("Please enter valid numeric values for Basic Pay and Medical Allowance.") 27 | Exit Sub 28 | End If 29 | 30 | ' Calculate Gross Pay 31 | Dim grossPay As Decimal = basicPay + medicalAllowance 32 | lblGrossPay.Text = "Gross Pay: " & grossPay.ToString("C") 33 | 34 | ' Calculate NSSF (5% of Gross Pay) 35 | Dim nssfContribution As Decimal = grossPay * 0.05D 36 | lblNSSF.Text = "NSSF Contribution: " & nssfContribution.ToString("C") 37 | 38 | ' Calculate Net Pay (Gross Pay - NSSF Contribution) 39 | Dim netPay As Decimal = grossPay - nssfContribution 40 | lblNetPay.Text = "Net Pay: " & netPay.ToString("C") 41 | 42 | ' Navigate to the third form (reportform) with the calculated data 43 | Dim reportForm As New reportform(grossPay, netPay) 44 | reportForm.Show() 45 | Me.Hide() 46 | End Sub 47 | End Class 48 | 49 | 50 | ' Code for ReportForm 51 | Public Class reportform 52 | 53 | Private grossPay As Decimal 54 | Private netPay As Decimal 55 | 56 | ' Constructor to pass Gross Pay and Net Pay from the second form 57 | Public Sub New(ByVal gPay As Decimal, ByVal nPay As Decimal) 58 | InitializeComponent() 59 | grossPay = gPay 60 | netPay = nPay 61 | End Sub 62 | 63 | Private Sub reportform_Load(sender As Object, e As EventArgs) Handles MyBase.Load 64 | lblGrossPayReport.Text = "Gross Pay: " & grossPay.ToString("C") 65 | lblNetPayReport.Text = "Net Pay: " & netPay.ToString("C") 66 | End Sub 67 | 68 | Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click 69 | ' Navigate back to the dataform 70 | Dim dataForm As New dataform() 71 | dataForm.Show() 72 | Me.Hide() 73 | End Sub 74 | End Class 75 | -------------------------------------------------------------------------------- /receiptForm.vb: -------------------------------------------------------------------------------- 1 | Public Class receiptForm 2 | Private Sub ReceiptForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load 3 | ' Calculate receipt details 4 | Dim subtotal As Decimal = DataEntryForm.quantity * DataEntryForm.pricePerItem 5 | Dim taxRate As Decimal = 0.18D 6 | Dim totalTax As Decimal = subtotal * taxRate 7 | Dim totalAmount As Decimal = subtotal + totalTax 8 | 9 | ' Display the receipt in the RichTextBox 10 | rtxtReceipt.Clear() 11 | rtxtReceipt.AppendText("China Town Store Uganda" & vbNewLine) 12 | rtxtReceipt.AppendText("Date of Purchase: " & DataEntryForm.dateOfPurchase.ToShortDateString() & vbNewLine) 13 | rtxtReceipt.AppendText("Served By: " & DataEntryForm.servedBy & vbNewLine) 14 | rtxtReceipt.AppendText("----------------------------" & vbNewLine) 15 | rtxtReceipt.AppendText("Customer Name: " & DataEntryForm.customerName & vbNewLine) 16 | rtxtReceipt.AppendText("Item: " & DataEntryForm.itemName & vbNewLine) 17 | rtxtReceipt.AppendText("Quantity: " & DataEntryForm.quantity.ToString() & vbNewLine) 18 | rtxtReceipt.AppendText("Price per Item: UGX " & DataEntryForm.pricePerItem.ToString("F2") & vbNewLine) 19 | rtxtReceipt.AppendText("Subtotal: UGX " & subtotal.ToString("F2") & vbNewLine) 20 | rtxtReceipt.AppendText("Tax (18%): UGX " & totalTax.ToString("F2") & vbNewLine) 21 | rtxtReceipt.AppendText("Total Amount: UGX " & totalAmount.ToString("F2") & vbNewLine) 22 | rtxtReceipt.AppendText("----------------------------" & vbNewLine) 23 | rtxtReceipt.AppendText("Thank you for shopping with us!") 24 | End Sub 25 | 26 | ' Back button to return to the Data Entry Form 27 | Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click 28 | ' Show the DataEntryForm 29 | Dim dataEntryForm As New DataEntryForm 30 | dataEntryForm.Show() 31 | ' Close the ReceiptForm 32 | Me.Close() 33 | End Sub 34 | 35 | ' Export to PDF functionality 36 | Private Sub btnExportToPDF_Click(sender As Object, e As EventArgs) Handles btnExportToPDF.Click 37 | Dim doc As New Document(PageSize.A4) 38 | Dim pdfFilePath As String = "C:\Receipts\Receipt.pdf" 39 | PdfWriter.GetInstance(doc, New FileStream(pdfFilePath, FileMode.Create)) 40 | 41 | doc.Open() 42 | doc.Add(New Paragraph(rtxtReceipt.Text)) 43 | doc.Close() 44 | 45 | MessageBox.Show("Receipt exported to PDF successfully!", "Export to PDF", MessageBoxButtons.OK, MessageBoxIcon.Information) 46 | End Sub 47 | 48 | ' Print functionality 49 | Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click 50 | Dim printDocument As New PrintDocument() 51 | AddHandler printDocument.PrintPage, AddressOf Me.PrintPageHandler 52 | PrintDialog1.Document = printDocument 53 | If PrintDialog1.ShowDialog() = DialogResult.OK Then 54 | printDocument.Print() 55 | End If 56 | End Sub 57 | 58 | Private Sub PrintPageHandler(sender As Object, e As PrintPageEventArgs) 59 | e.Graphics.DrawString(rtxtReceipt.Text, New Font("Arial", 12), Brushes.Black, 100, 100) 60 | End Sub 61 | End Class 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /umemeForecast.vb: -------------------------------------------------------------------------------- 1 | Public Class umemeForecast 2 | Private Sub btnFixedChargesTotal_Click(sender As Object, e As EventArgs) Handles btnFixedChargesTotal.Click 3 | ' Calculate the Fixed Charges Total 4 | Dim serviceFee As Decimal = CDec(txtServiceFee.Text) 5 | Dim vat As Decimal = CDec(txtVAT.Text) 6 | Dim fixedChargesTotal As Decimal = serviceFee + vat 7 | 8 | ' Display the result in the Fixed Charges Total textbox 9 | txtFixedChargesTotal.Text = fixedChargesTotal.ToString() 10 | End Sub 11 | 12 | 13 | Private Sub btnTotalCost_Click(sender As Object, e As EventArgs) Handles btnTotalCost.Click 14 | ' Calculate the total cost 15 | Dim unitsPurchased As Decimal = CDec(txtUnitsPurchased.Text) 16 | Dim unitCost As Decimal = 780 17 | Dim fixedChargesTotal As Decimal = CDec(txtFixedChargesTotal.Text) 18 | Dim totalCost As Decimal = (unitsPurchased * unitCost) + fixedChargesTotal 19 | 20 | ' Display the result in the Total Cost textbox 21 | txtTotalCost.Text = totalCost.ToString() 22 | End Sub 23 | 24 | End Class --------------------------------------------------------------------------------