VB.net Problem

vb.net Kenya
  • 13 years ago
    I am currently studying to be an ICT secondary teacher and as part of my training we have to complete a computer programming module. We have been using Visual Basic.net to solve problems. I have a problem which i can not solve and would be glad of an advice anybody could give.Problem (simple enough) - A disco can hold 500 people.  Allow the user to keep entering the number of people in each group as the group comes through the door.  Display the running total and how many people are allowed in before it becomes full.  When the running total reaches exactly 500, display a message that the disco is full, or if 500 would be exceeded, a message that the current group of people cannot go in.Analysis:Input:Ask user to enter Number - Store number (variable called EnterNumb)Process:Subtract EnterNum from 500 (MaxNumber)The remaining number of spaces is displayed in NumSpacesleftMessage to appear – Disco Full if = 50 or if number >500, message to appear current group can not go in, to keep looping until total = 500 or no more can fit in.Print Answer.So the code i have so far is: (it does not work - anybody help?)

     

    Dim Number, Result, Maxnumber As Short

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click

    Number = 0 'written by Theresa Russell Dec 07

    Result = 0 'sets Number and Results to zero to start with

    Maxnumber = 500 'maximum number allowed in disco

     

    Do

    Number = txtEnterNumb.Text 'number entered by user

    Result = Number + Result 'Result = current total

    txtCurrentTotal.Text = Result

    txtNumSpacesLeft.Text = Maxnumber - Result ' 500 - total number of people enter disco

    Loop Until Result >= 500

    If Result = 500 Then

    MsgBox("Disco Full - no more allowed")

     

     

    ElseIf Result + Number > 500 Then

    MsgBox("Too many in the group")

    Result = Result - Number

    txtCurrentTotal.Text = (Maxnumber - Result)

    txtNumSpacesLeft.Text = Result

    End If

    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

    Dim Message As String = "Are you sure you want to exit?"

    Dim Caption As String = "Disco"

    Dim Buttons As MessageBoxButtons = MessageBoxButtons.YesNo

    Dim Result As DialogResult

    Result = MessageBox.Show(Me, Message, Caption, Buttons)

    If Result = DialogResult.Yes Then

    Me.Close()

    End If

    End Sub

    End Class

     

     

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Nine people can't make a baby in a month.” - Fred Brooks