13 Replies - 33744 Views - Last Post: 16 March 2011 - 02:09 PM Rate Topic: -----

#1 tim99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-March 11

Looking for help with a Weekly pay calculator

Posted 08 March 2011 - 10:06 PM

Option Strict On

Public Class frmweeklypaycalculator
    '
    Const cintNumberOfMinutesInHour As Integer = 60


    Private Sub btnweeklypay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWeeklyPay.Click
        ' This event handler is executed when the user clicks the
        ' Weekly Pay button. It calculates and displays the
        ' number of hours worked (total minutes worked divided by
        ' 60), the number of minutes worked (use mod operator to
        ' times hour remainder by 60), and the Total amount to
        ' be paid (hours worked times hourly pay rate).

        Dim strTotalMinutesWorked As String
        Dim intTotalMinutesWorked As Integer
        Dim strHourlyPayRate As String
        Dim decHourlyPayRate As Decimal
        Dim intTotalHoursWorked As Integer
        Dim intTotalLeftoverMinutes As Integer
        Dim decTotalWeeklyPay As Decimal

        strTotalMinutesWorked = Me.txtTotalMinutesWorked.Text
        strHourlyPayRate = Me.txtHourlyPayRate.Text
        intTotalHoursWorked = intTotalMinutesWorked \ 60
        intTotalMinutesWorked = intTotalLeftoverMinutes Mod 60
        decTotalWeeklyPay = Convert.ToDecimal(intTotalMinutesWorked) / _
        Convert.ToDecimal(cintNumberOfMinutesInHour = 60) * decHourlyPayRate



        Me.lblTotalHoursWorked.Text = decHourlyPayRate.ToString("")
        Me.lblTotalWeeklyPay.Text = decTotalWeeklyPay.ToString("C")
        Me.lblTotalLeftoverMinutes.Text = intTotalLeftoverMinutes.ToString("")

        Me.lblTotalHoursWorked.Text = decTotalWeeklyPay.ToString("")
        Me.lblTotalWeeklyPay.Text = decTotalWeeklyPay.ToString("C")
        Me.lblTotalLeftoverMinutes.Text = intTotalLeftoverMinutes.ToString("")

    End Sub

    Private Sub Btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        ' This Event Handler is executed when the user clicks the
        ' clear button. It clears the number of mintutes worked text box,
        ' the text property of minutes worked, the hourly rate text box,
        ' the textproperty of hours worked, and the text propoerty of
        ' weekly pay.

        Me.txtTotalMinutesWorked.Clear()
        Me.txtHourlyPayRate.Clear()
        Me.lblTotalHoursWorked.Text = ""
        Me.lblTotalWeeklyPay.Text = ""
        Me.lblTotalLeftoverMinutes.Text = ""
        Me.txtTotalMinutesWorked.Focus()

    End Sub

    Private Sub Btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        ' This event handler is executed when the user clicks the
        ' Exit button. It closes the window and terminates the
        ' application.

        Me.Close()

    End Sub
End Class


If someone could help give me a push in the right direction that would be great I'm just starting this and I'm very new to it :surrender:


Attached Image
Attached Image
Attached Image

This should not be in the code twice


  Me.lblTotalHoursWorked.Text = decHourlyPayRate.ToString("")
        Me.lblTotalWeeklyPay.Text = decTotalWeeklyPay.ToString("C")
        Me.lblTotalLeftoverMinutes.Text = intTotalLeftoverMinutes.ToString("")

This post has been edited by AdamSpeight2008: 09 March 2011 - 10:03 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Looking for help with a Weekly pay calculator

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 16480
  • View blog
  • Posts: 65,328
  • Joined: 12-June 08

Re: Looking for help with a Weekly pay calculator

Posted 08 March 2011 - 10:17 PM

Tim, you are going to have to explain what is going on (or not going on) better. What is your not doing? What is your supposed to be doing? Is there an error? Where? What line? Etc..
Was This Post Helpful? 0
  • +
  • -

#3 tim99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-March 11

Re: Looking for help with a Weekly pay calculator

Posted 08 March 2011 - 11:32 PM

I need the numbers in the pictures to show up as the hours worked, Leftover minutes and the weekly pay and all I'm getting are zero's when I calculate the weekly pay, also it is not showing any error's, I don't know what I'm not putting in the code to calculate Hours worked-Leftover minutes and weekly pay. Hours worked should be calculated by: Minutes worked\number of minutes in a hour with an Integer division. Leftover minutes would be Minutes worked MOD number of minutes in a hour with a MOD operator. Weekly pay i need to convert the minutes worked and number of minutes in a hour variables to decimal in the calculation for example " decWeeklyPay = Convert.ToDecimal(intMinutesWorked)\Convert.ToDecimal(cintNumberOfMinutesInHour) * decPayRate.
Also is this correct for a constant Variable - Const cintNumberOfMinutesInHour As Integer = 60
Noy asking to much Sorry but i would appreciate the help

This post has been edited by AdamSpeight2008: 09 March 2011 - 10:02 PM

Was This Post Helpful? 0
  • +
  • -

#4 tim99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-March 11

Re: Looking for help with a Weekly pay calculator

Posted 09 March 2011 - 08:57 AM

Well I finally figured it out

This post has been edited by AdamSpeight2008: 09 March 2011 - 10:02 PM

Was This Post Helpful? 0
  • +
  • -

#5 tim99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-March 11

Re: Looking for help with a Weekly pay calculator

Posted 09 March 2011 - 09:02 AM

Attached Image
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 16480
  • View blog
  • Posts: 65,328
  • Joined: 12-June 08

Re: Looking for help with a Weekly pay calculator

Posted 09 March 2011 - 09:57 AM

Well kudos for getting over the problem. What did you do to solve it?
Was This Post Helpful? 0
  • +
  • -

#7 tim99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-March 11

Re: Looking for help with a Weekly pay calculator

Posted 09 March 2011 - 10:08 AM

This is the code I used, I had my contant variable set and i was'nt using it lol Also my intTotalHoursWorked was not set to lblTotalHoursWorked

Option Strict On

Public Class frmweeklypaycalculator
    '
    Const cintNumberOfMinutesInHour As Integer = 60


    Private Sub btnweeklypay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWeeklyPay.Click
        ' This event handler is executed when the user clicks the
        ' Weekly Pay button. It calculates and displays the
        ' number of hours worked (total minutes worked divided by
        ' 60), the number of minutes worked (use mod operator to
        ' times hour remainder by 60), and the Total amount to
        ' be paid (hours worked times hourly pay rate).

        Dim strTotalMinutesWorked As String
        Dim intTotalMinutesWorked As Integer
        Dim strHourlyPayRate As String
        Dim decHourlyPayRate As Decimal
        Dim intTotalHoursWorked As Integer
        Dim intTotalLeftoverMinutes As Integer
        Dim decTotalWeeklyPay As Decimal

        strTotalMinutesWorked = Me.txtTotalMinutesWorked.Text
        intTotalMinutesWorked = Convert.ToInt32(strTotalMinutesWorked)
        strHourlyPayRate = Me.txtHourlyPayRate.Text
        decHourlyPayRate = Convert.ToDecimal(strHourlyPayRate)
        intTotalHoursWorked = intTotalMinutesWorked \ cintNumberOfMinutesInHour
        intTotalLeftoverMinutes = intTotalMinutesWorked Mod cintNumberOfMinutesInHour
        decTotalWeeklyPay = Convert.ToDecimal(intTotalMinutesWorked) / Convert.ToDecimal(cintNumberOfMinutesInHour) * decHourlyPayRate

        Me.lblTotalHoursWorked.Text = intTotalHoursWorked.ToString("")
        Me.lblTotalWeeklyPay.Text = decTotalWeeklyPay.ToString("C")
        Me.lblTotalLeftoverMinutes.Text = intTotalLeftoverMinutes.ToString("")

    End Sub

    Private Sub Btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        ' This Event Handler is executed when the user clicks the
        ' clear button. It clears the number of mintutes worked text box,
        ' the text property of minutes worked, the hourly rate text box,
        ' the textproperty of hours worked, and the text propoerty of
        ' weekly pay.

        Me.txtTotalMinutesWorked.Clear()
        Me.txtHourlyPayRate.Clear()
        Me.lblTotalHoursWorked.Text = ""
        Me.lblTotalWeeklyPay.Text = ""
        Me.lblTotalLeftoverMinutes.Text = ""
        Me.txtTotalMinutesWorked.Focus()

    End Sub

    Private Sub Btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        ' This event handler is executed when the user clicks the
        ' Exit button. It closes the window and terminates the
        ' application.

        Me.Close()

    End Sub
End Class

This post has been edited by AdamSpeight2008: 09 March 2011 - 10:02 PM

Was This Post Helpful? 0
  • +
  • -

#8 AdamSpeight2008   User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: Looking for help with a Weekly pay calculator

Posted 09 March 2011 - 10:04 PM

tim99: You only need to put your code extracts inside of the codetags.
Was This Post Helpful? 0
  • +
  • -

#9 tim99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-March 11

Re: Looking for help with a Weekly pay calculator

Posted 09 March 2011 - 10:24 PM

Ok sorry bout that
Was This Post Helpful? 0
  • +
  • -

#10 lcburkett   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 16-March 11

Re: Looking for help with a Weekly pay calculator

Posted 16 March 2011 - 12:53 PM

View Posttim99, on 09 March 2011 - 09:02 AM, said:



Did you figure it out I doing the same project but can't get in to calculate. This is what I got

 Dim intTotalNumberOfMinutes As Integer
        Dim strTotalNumberOfMinutes As String
        Dim intHourlyPayRate As Integer
        Dim strHoursWorked As String
        Dim intHoursWorked As Integer
        Dim strMinutesLeft As String
        Dim intMinutesLeft As Integer
        Dim decTotalWeeklyPay As Decimal
        

        strTotalNumberOfMinutes = txtTotalNumberOfMinutes.Text
        intTotalNumberOfMinutes = Convert.ToInt32(strTotalNumberOfMinutes)
        strHoursWorked = lblHoursWorked.Text
        intHoursWorked = Convert.ToInt32(strHoursWorked)
        strMinutesLeft = lblMinutesLeft.Text
        intMinutesLeft = Convert.ToInt32(strMinutesLeft)
        decTotalWeeklyPay = (intHourlyPayRate \ 60) * intTotalNumberOfMinutes
        intHoursWorked = intTotalNumberOfMinutes \ 60
        intMinutesLeft = intTotalNumberOfMinutes Mod 60
        lblHoursWorked.Text = intHoursWorked.ToString("G")
        lblMinutesLeft.Text = intMinutesLeft.ToString("G")
        lblTotalWeeklyPay.Text = decTotalWeeklyPay.ToString("C")

This post has been edited by modi123_1: 16 March 2011 - 12:54 PM
Reason for edit:: please use code tags

Was This Post Helpful? 0
  • +
  • -

#11 tim99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-March 11

Re: Looking for help with a Weekly pay calculator

Posted 16 March 2011 - 01:32 PM

What are you taking exactly

This post has been edited by tim99: 16 March 2011 - 01:35 PM

Was This Post Helpful? 0
  • +
  • -

#12 lcburkett   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 16-March 11

Re: Looking for help with a Weekly pay calculator

Posted 16 March 2011 - 01:51 PM

View Posttim99, on 16 March 2011 - 01:32 PM, said:

What are you taking exactly


I am taking Visual Basic 2010
Was This Post Helpful? 0
  • +
  • -

#13 tim99   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-March 11

Re: Looking for help with a Weekly pay calculator

Posted 16 March 2011 - 02:05 PM

I'm taking VB 2008 - right now i'm working on Ch7 Case Programming 1 Cruise Reservation Web Application
Was This Post Helpful? 0
  • +
  • -

#14 lcburkett   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 16-March 11

Re: Looking for help with a Weekly pay calculator

Posted 16 March 2011 - 02:09 PM

I doing western Distribution Weekly payroll Calculation I can't get it to calculate

This post has been edited by lcburkett: 16 March 2011 - 02:10 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1