Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
19 views10 pages

VB Project Exercise

The document outlines multiple projects including a calendar display, a student grade determination system, a stopwatch, and a statistical calculator. Each project includes user interface elements and logic for handling inputs, calculations, and outputs. The code snippets demonstrate the implementation of features such as time display, grade calculation based on categories, and statistical computations like mean and standard deviation.

Uploaded by

josephjuwon77
Copyright
© © All Rights Reserved
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)
19 views10 pages

VB Project Exercise

The document outlines multiple projects including a calendar display, a student grade determination system, a stopwatch, and a statistical calculator. Each project includes user interface elements and logic for handling inputs, calculations, and outputs. The code snippets demonstrate the implementation of features such as time display, grade calculation based on categories, and statistical computations like mean and standard deviation.

Uploaded by

josephjuwon77
Copyright
© © All Rights Reserved
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/ 10

PROJECT ; Design of a calender

Option Explicit

Private Sub cmdExit_Click()

End

End Sub

Private Sub timDisplay_Timer()

Dim Today As Variant

Today = Now

lblDay.Caption = Format(Today, "dddd")

lblMonth.Caption = Format(Today, "mmmm")

lblYear.Caption = Format(Today, "yyyy")

lblNumber.Caption = Format(Today, "d")

lblTime.Caption = Format(Today, "h:mm:ss ampm")

End Sub
PROJECT: DETERMINATION OF STUDENT GRADE

INPUT SCREEN

Option Explicit

Dim ca, pe, we, m As Double

Dim g, textval As String

Dim a, b As Double

OU

Private Sub cmdCMG_Click()

ca = Val(txtCA.Text)

pe = Val(txtPE.Text)

we = Val(txtWE.Text)
m = ((ca + pe + we) / 150) * 100

'textval = cmbCAT

'cat

If cmbCAT.Text = "CATEGORY 1" Then

a = 0.85

b = 0.95

ElseIf cmbCAT.Text = "CATEGORY 2" Then

a = 0.8

b = 0.9

ElseIf cmbCAT.Text = "CATEGORY 3" Then

a = 0.95

b = 0.95

ElseIf cmbCAT.Text = "CATEGORY 4" Then

a = 0.85

b = 1.05

End If

m=m*a*b

If m >= 39 Then

g = "PASS"

ElseIf m < 39 Then

g = "FAIL"

End If

If ca < 20 Or pe < 20 Or we < 20 Then

m = 39
g = "TECHNICAL FAILURE"

MsgBox "this student do not get up to 20 marks in one component = technical failure"

'GoTo hh

End If

'hh:

frmResult.Show

'frmResult.txtResultm = CInt(m)

frmResult.txtResultm = CInt(m)

frmResult.txtResultg = g

Me.Hide

'If Val(txtNum2.Text) = 0 Then

'MsgBox "second number canot be zero adjust"

'txtNum2.SetFocus

''SendKeys "{home}+{end}"

'Exit Sub

' End If

End Sub

Private Sub Form_Load()

With cmbCAT

.AddItem "CATEGORY 1"

.AddItem "CATEGORY 2"

.AddItem "CATEGORY 3"

.AddItem "CATEGORY 4"

End With
End Sub

OUTPUT SCREEN
STOPWATCH PROJECT

Option Explicit

Dim StartTime As Variant

Dim EndTime As Variant

Dim ElapsedTime As Variant

Sub cmdStart_Click()

'Establish and print starting time

StartTime = Now

lblStart.Caption = Format(StartTime, "hh:mm:ss")

lblEnd.Caption = ""

lblElapsed.Caption = ""

End Sub

Sub cmdEnd_Click()

'Find the ending time, compute the elapsed time

'Put both values in label boxes

EndTime = Now

ElapsedTime = EndTime - StartTime

lblEnd.Caption = Format(EndTime, "hh:mm:ss")


lblElapsed.Caption = Format(ElapsedTime, "hh:mm:ss")

End Sub

Sub cmdExit_Click()

End

End Sub
Option Explicit

'Dim NumValues As Integer

Public NumValues As Integer

Dim SumX As Single

Dim SumX2 As Single

Const vbKeyMinus = 45

Const vbKeyDecPt = 46

Private Sub cmdAccept_Click()

Dim Value As Single

NumValues = NumValues + 1

lblNumber.Caption = NumValues 'Str(NumValues)


'Get number and sum number and number-squared

Value = Val(txtInput.Text)

SumX = SumX + Value

SumX2 = SumX2 + Value ^ 2

txtInput.Text = ""

txtInput.SetFocus

End Sub

Private Sub cmdCompute_Click()

Dim Mean As Single

Dim StdDev As Single

txtInput.SetFocus

'Make sure there are at least two values

If NumValues < 2 Then

Beep

Exit Sub

End If

'Compute Mean

Mean = SumX / NumValues

lblMean.Caption = Str(Mean)

'Compute standard deviation

StdDev = Sqr((NumValues * SumX2 - SumX ^ 2) / (NumValues * (NumValues - 1)))

lblStdDev.Caption = Str(StdDev)

End Sub

Private Sub cmdExit_Click()

End

End Sub

Private Sub cmdNew_Click()

'Initialize all variables

txtInput.SetFocus
NumValues = 0

lblNumber.Caption = "0"

txtInput.Text = ""

lblMean.Caption = ""

lblStdDev.Caption = ""

SumX = 0

SumX2 = 0

End Sub

Private Sub txtInput_KeyPress(KeyAscii As Integer)

'Only allow numbers, minus sign, decimal point, backspace,return keys

If (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or KeyAscii = vbKeyMinus Or KeyAscii = vbKeyBack Then
'Or KeyAscii = vbKeyDecPt

Exit Sub

ElseIf KeyAscii = vbKeyReturn Then

Call cmdAccept_Click

Else

KeyAscii = 0

End If

End Sub

You might also like