0% found this document useful (0 votes)
76 views

Codes

The document contains code for several different VB.NET forms applications: 1. A login form that validates username and password and displays a welcome message or error based on the input. 2. A form that displays numbers in a range incrementally in a list box. 3. A product search form that searches an array of product IDs and displays the price and name if found. 4. Additional forms and classes for concert ticket booking, displaying school data from an array in a list box, purchasing t-shirts, and other tasks.

Uploaded by

boardtopnotch
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Codes

The document contains code for several different VB.NET forms applications: 1. A login form that validates username and password and displays a welcome message or error based on the input. 2. A form that displays numbers in a range incrementally in a list box. 3. A product search form that searches an array of product IDs and displays the price and name if found. 4. Additional forms and classes for concert ticket booking, displaying school data from an array in a list box, purchasing t-shirts, and other tasks.

Uploaded by

boardtopnotch
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

LOG-IN Public Class frmlogin Dim pass, user As String Dim response As Integer Private Sub btnCancel_Click(ByVal sender

As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click Me.Close() End Sub Private Sub txtPassword_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPassword.TextChanged End Sub Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click pass = txtPassword.Text user = txtusername.Text If pass = "krizia03" And user = "irlandez" Then lblmessage.Text = "WELCOME!" Me.BackColor = Color.Yellow Else Me.BackColor = Color.Red response = MessageBox.Show("Would you like to try again?", "Try Again", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If response = vbYes Then Me.Show() txtPassword.Clear() txtusername.Clear() Me.BackColor = Color.Snow txtusername.Focus() lblmessage.Text = "" Else Me.Close() End If End If End Sub

DISPLAY IN LIST BOX


Public Class Form1 Dim max, interval As Integer Private Sub btndisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndisplay.Click lstresult.Items.Clear() max = txtmax.Text interval = txtinterval.Text For result As Integer = 0 To max Step interval lstresult.Items.Add(result) Next result

End Sub Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click txtinterval.Clear() txtmax.Clear() lstresult.Items.Clear() txtmax.Focus() End Sub End Class

PRODUCT SEARCH
Public Class Form1 Dim ID() As String = {"BB9900", "IP432", "SGGS2", "SXP10", "MTRZR"} Dim prices() As Double = {32500, 35600, 28900, 25900, 32100} Dim prodnames() As String = {"BlackBerry 9900", "Apple iPhone 4 32GB", "Samsung Galaxy S2", "Sony Ericsson Experia X10", "Motorola Razr"} Dim searchid As String Dim subscript As Integer Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click Me.Close() End Sub Private Sub btndisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndisplay.Click subscript = 0 searchid = UCase(txtProdId.Text)

Do Until subscript = ID.Length OrElse searchid = ID(subscript) subscript = subscript + 1 Loop If subscript >= ID.Length Then MessageBox.Show("Invalid Product ID!", "Cellphone Shop", MessageBoxButtons.OK, MessageBoxIcon.Information) txtProdId.Clear() lblmessage.Text = "" txtProdId.Focus() Else MessageBox.Show("Record Found!", "FOUND!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) lblmessage.Text = "Php " & prices(subscript).ToString("N") lblprodname.Text = prodnames(subscript) End If End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub lbl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl1.MouseHover Me.BackColor = Color.DeepSkyBlue End Sub Private Sub lbl2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbl2.MouseHover Me.BackColor = Color.LimeGreen End Sub Private Sub btnnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnew.Click txtProdId.Clear() lblprodname.Text = "" lblmessage.Text = "" txtProdId.Focus() End Sub

CONCERT TICKET
Public Class frmticketing Public seats() As String = {"Patron VIP", "Patron", "Lower Box A", "Upper Box A", "Upper Box B", "General Admission"} Public prices() As Double = {4500, 4000, 3000, 2300, 1200, 600} Public ticketcount(seats.GetUpperBound(0)) As Integer Public subscript As Integer Public totnumber, totsales, number, response As Double Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click Me.Close() End Sub Private Sub btnsummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsummary.Click Me.Hide() frmsummary.Show() frmsummary.lblvip.Text frmsummary.lbla.Text = frmsummary.lblp.Text = frmsummary.lblb.Text = frmsummary.lbll.Text = frmsummary.lblg.Text = = lblvip.Text lbla.Text lblp.Text lblb.Text lbll.Text lblg.Text

frmsummary.lbltotnumber.Text = totnumber frmsummary.lbltotsales.Text = "Php " & totsales.ToString("N") End Sub Private Sub btnenter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenter.Click

number = 0

If txtnumber.Text = "" Then MessageBox.Show("Please input number of tickets.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop) Else number = txtnumber.Text response = MessageBox.Show("Total Tickets for Purchase: " & number & vbCrLf & "Total Amount to be Paid: Php " & (number * prices(lstseats.SelectedIndex)).ToString("n") & vbCrLf & "Complete transaction?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If response = vbYes Then totsales = totsales + number * prices(lstseats.SelectedIndex) ticketcount(lstseats.SelectedIndex) = number + ticketcount(lstseats.SelectedIndex) totnumber = totnumber + number lblvip.Text = ticketcount(0) lblp.Text = ticketcount(1) lbll.Text = ticketcount(2) lbla.Text = ticketcount(3) lblb.Text = ticketcount(4) lblg.Text = ticketcount(5) txtnumber.Clear() lblprice.Text = "" Else txtnumber.Clear() lblprice.Text = "" txtnumber.Focus() End If End If

End Sub Private Sub lstseats_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstseats.SelectedIndexChanged lblprice.Text = "Php " & prices(lstseats.SelectedIndex).ToString("N") End Sub Private Sub frmticketing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For subscript As Integer = 0 To seats.GetUpperBound(0) lstseats.Items.Add(seats(subscript)) Next subscript End Sub End Class

ARRAY IN LISTBOX
Public Class Form1 Dim schools(,) As String = {{"UST", "University of Santo Tomas", "Manila"}, {"ADMU", "Ateneo De Manila University", "QC"}, {"DLSU", "De La Salle University", "Manila"},

{"UPD", "University of the Philippine Diliman", "QC"}, {"SBC", "San Beda College", "Manila"}} Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstschools.SelectedIndexChanged End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click lstschools.Items.Clear() For numrow As Integer = 0 To schools.GetUpperBound(0) For numcol As Integer = 0 To schools.GetUpperBound(1) lstschools.Items.Add(schools(numrow, numcol)) Next numcol Next numrow End Sub End Class

T-SHIRT
Public Class frmust Dim shirt() As String = {"UST Unending Grace White", "UST Unending Grace Yellow", "UST Unending Grace Black", "UST 400 Yellow", "UST 400 Black", "Viva Santo Tomas Black", "Santo Tomas Yellow"} Dim sprice() As Double = {350, 400, 400, 500, 500, 420, 450} Dim stock() As Integer = {100, 100, 100, 100, 100, 100, 100} Dim snumber, response, sbuy As Double Private Sub frmust_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For subscript As Integer = 0 To shirt.GetUpperBound(0) cmbshirts.Items.Add(shirt(subscript)) Next subscript

End Sub Private Sub btnpurchase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnpurchase.Click snumber = 0 If txtsnumber.Text = "" Then MessageBox.Show("Please select an item and input the quantity.", "Incomplete Transaction", MessageBoxButtons.OK, MessageBoxIcon.Information) txtsnumber.Focus() Else If stock(cmbshirts.SelectedIndex) < txtsnumber.Text Then response = MessageBox.Show("You don't have enough stocks." & vbCrLf & "Would you like to add more stock?", "Not enough stocks left.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If response = vbYes Then stock(cmbshirts.SelectedIndex) = stock(cmbshirts.SelectedIndex) + 100 lblUGwhite.Text = stock(0) lblUGyellow.Text = stock(1) lblUGblack.Text = stock(2) lbl400yellow.Text = stock(3)

lbl400black.Text = stock(4) lblviva.Text = stock(5) lblSTyellow.Text = stock(6) End If Else snumber = txtsnumber.Text response = MessageBox.Show("You ordered " & snumber & " pc/s. of " & shirt(cmbshirts.SelectedIndex) & " shirt/s." & vbCrLf & "Please pay: Php " & (snumber * sprice(cmbshirts.SelectedIndex)).ToString("N") & vbCrLf & "Confirm transaction?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If response = vbYes Then stock(cmbshirts.SelectedIndex) = stock(cmbshirts.SelectedIndex) snumber lblUGwhite.Text = stock(0) lblUGyellow.Text = stock(1) lblUGblack.Text = stock(2) lbl400yellow.Text = stock(3) lbl400black.Text = stock(4) lblviva.Text = stock(5) lblSTyellow.Text = stock(6) cmbshirts.SelectedIndex = -1 lblprice.Text = "" txtsnumber.Clear() cmbshirts.Focus() Else cmbshirts.SelectedIndex = -1 lblprice.Text = "" txtsnumber.Clear() cmbshirts.Focus() End If End If End If End Sub Private Sub cmbshirts_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbshirts.SelectedIndexChanged If cmbshirts.SelectedIndex = -1 Then lblprice.Text = "" Else lblprice.Text = "Php " & sprice(cmbshirts.SelectedIndex).ToString("N") End If End Sub

You might also like