Hi everyone, I am trying to make a program for my boyfriend to use at his business to keep track of cover charges. I am so lost as to what loop structure to put in and where to put it. If someone could take a look and please let me know what I should do I would really appreciate it. Thank you.

Private Sub btnCoverEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCoverEnter.Click
Dim deczerocover As Decimal = 0D
Dim decfivecover As Decimal = 5D
Dim deceightcover As Decimal = 8D
Dim dectencover As Decimal = 10D
Dim deccover As Decimal
Dim dectotalcover As Decimal
Dim intnumberofentries As Integer = 1
Dim intmaxnumberofentries As Integer = 100
'choose a radio button and then click enter button.
'each entry will appear in a listbox along with keeping a running total
'of all monies in the drawer

If radZero.Checked Then
deccover = deczerocover
ElseIf radFive.Checked Then
deccover = decfivecover
ElseIf radEight.Checked Then
deccover = deceightcover
ElseIf radTen.Checked Then
deccover = dectencover

End If

lblCover.Text = deccover
lstCover.Items.Add(deccover)

dectotalcover = dectotalcover + deccover
lbltotalcover.Text = dectotalcover


End Sub

Tell us what you are trying to do. Saying "I need to keep track of cover charges" doesn't tell us anything. Describe the process. Tell us what you want the user to do and what you want to do with the data. The more info you provide the better we are able to help.

One more thing - when you post code please enclose it in "code" tags. The easiest way to do that is to paste the code, then select it, then click on the CODE tool at the top of the edit box. Doing this will preserve formatting and make the code easier to read.

Edited 4 Years Ago by Reverend Jim: n/a

Thanks Reverend Jim, I wasn't sure how to do that. Basically the purpose is to choose a radio button (free cover aka zero, five, eight and ten), click the enter button, and a running total will be kept in a list box so he can keep track of how many people and the program will also keep a running total of the money collected in a label. I have only studied beginning VB and this is probably more complicated than what I can handle.

Private Sub btnCoverEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCoverEnter.Click
        Dim deczerocover As Decimal = 0D
        Dim decfivecover As Decimal = 5D
        Dim deceightcover As Decimal = 8D
        Dim dectencover As Decimal = 10D
        Dim deccover As Decimal
        Dim dectotalcover As Decimal
        Dim intnumberofentries As Integer = 1
        Dim intmaxnumberofentries As Integer = 100
        'choose a radio button and then click enter button.  
        'each entry will appear in a listbox along with keeping a running total
        'of all monies in the drawer
        Do While btnCoverEnter
            If radZero.Checked Then
                deccover = deczerocover
            ElseIf radFive.Checked Then
                deccover = decfivecover
            ElseIf radEight.Checked Then
                deccover = deceightcover
            ElseIf radTen.Checked Then
                deccover = dectencover

            End If

            lblCover.Text = deccover
            lstCover.Items.Add(deccover)

            dectotalcover = dectotalcover + deccover
            lbltotalcover.Text = dectotalcover

        Loop
    End Sub

This will do a simple tally. However, it doesn't provide a way to correct mistakes such as incorrectly selecting the wrong cover charge and clicking "Add", but it should get you started.

Public Class Form1

    Private totalPeople As Integer      'number of people admitted      
    Private totalMoney As Decimal       'total cover charges collected  

    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load

        totalPeople = 0
        totalMoney = 0D

    End Sub

    Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click

        'increment total cover charge collected and number of people admitted

        If radFive.Checked Then
            totalMoney += 5D
        ElseIf radEight.Checked Then
            totalMoney += 8D
        ElseIf radTen.Checked Then
            totalMoney += 10D
        End If

        totalPeople += 1

        'update displayed values

        lblPeople.Text = totalPeople.ToString
        lblMoney.Text = FormatCurrency(totalMoney, 2)

        'reset cover charge to default

        radTen.Checked = True

    End Sub

End Class

Edited 4 Years Ago by Reverend Jim: n/a

This article has been dead for over six months. Start a new discussion instead.