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

Word Code 4 4

This code defines constants for maximum weight and volume allowed for packages. It gets dimensions and calculates volume from user input fields. When a button is clicked, it checks if the weight or volume exceeds the limits, and displays the appropriate rejection message, or an acceptance message if within limits.

Uploaded by

api-308557409
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)
20 views

Word Code 4 4

This code defines constants for maximum weight and volume allowed for packages. It gets dimensions and calculates volume from user input fields. When a button is clicked, it checks if the weight or volume exceeds the limits, and displays the appropriate rejection message, or an acceptance message if within limits.

Uploaded by

api-308557409
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/ 1

Chapter 4, Exercise 4:

Public Class Form1


Const MAXWEIGHT As Integer = 27
Const MAXVOLUME As Integer = 100000
Dim weight As Integer
Dim length As Integer
Dim packageWidth As Integer
Dim height As Integer
Dim volume As Integer
Private Sub btnCheckPackage_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCheckPackage.Click
weight = Val(txtWeight.Text)
length = Val(txtLength.Text)
packageWidth = Val(txtWidth.Text)
height = Val(txtHeight.Text)
volume = length * packageWidth * height
If weight > MAXWEIGHT And volume > MAXVOLUME Then
lblMessage.Text = "Rejected: too heavy and too large"
ElseIf weight > MAXWEIGHT Then
lblMessage.Text = "Rejected: too heavy"
ElseIf volume > MAXVOLUME Then
lblMessage.Text = "Rejected:too large"
ElseIf weight <= MAXWEIGHT And weight > 0 Then
lblMessage.Text = "Package accepted"
ElseIf volume <= MAXVOLUME And volume > 0 Then
lblMessage.Text = "Package accepted"
End If
End Sub
End Class

You might also like