You are here: DEVPPL Forum Programming Visual Basic Forum
NOTIFICATIONS
54.052
MEMBERS
15.676
TOPICS
62.235
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

Private Sub = Call(function) HELP PLEASE

0

Loading

Private Sub = Call(function) HELP PLEASE

Postby Routy » Mon Oct 24, 2011 3:48 am

I'm trying to call a function to my private sub and it's not working. Can someone look at code and tell me what may be the problem.

Trying to call GETFWT to private sub GETFWT I put ( HELP 1) HELP 1 END) throughout code. There are three HELP sections that all tie together. Please look at that code. Just a few lines need to be tweaked and I'm having issues getting it to pull in my Federal Withholding on my form. It keeps coming up zero.

Option Explicit On
Option Strict On
Option Infer Off

Public Class frmMain

HELP 1)

Private Sub GetFwt(ByVal strMarital As String,
ByVal intNumAllow As Integer,
ByVal dblWeekPay As Double,
ByRef dblFwt As Double)
' calculates and returns the FWT

HELP 1 end)




Const dblONE_ALLOW As Double = 70.19
Dim dblTaxWages As Double
Dim dblTax As Double
' calculate taxable wages
dblTaxWages =
dblWeekPay - intNumAllow * dblONE_ALLOW

' determine marital status and then calculate FWT
If strMarital = "S" Then
Select Case dblTaxWages
Case Is <= 116D
dblTax = 0D
Case Is <= 200D
dblTax = 0.1D * (dblTaxWages - 116D)
Case Is <= 693D
dblTax = 8.4D + 0.15D * (dblTaxWages - 200D)
Case Is <= 1302D
dblTax = 82.35D + 0.25D * (dblTaxWages - 693D)
Case Is <= 1624D
dblTax = 234.6D + 0.27D * (dblTaxWages - 1302D)
Case Is <= 1687D
dblTax = 321.54D + 0.3D * (dblTaxWages - 1624D)
Case Is <= 33447D
dblTax = 340.44D + 0.28D * (dblTaxWages - 1687D)
Case Is <= 7225D
dblTax = 804.4D + 0.33D * (dblTaxWages - 3344D)
Case Else
End Select
Else ' strMarital = "M"
Select Case dblTaxWages
Case Is <= 264D
dblTax = 0D
Case Is <= 471D
dblTax = 0.1D * (dblTaxWages - 264D)
Case Is <= 1457D
dblTax = 20.7D + 0.15D * (dblTaxWages - 471D)
Case Is <= 1809D
dblTax = 168.8D + 0.25D * (dblTaxWages - 1457D)
Case Is <= 2386D
dblTax = 256.6D + 0.27D * (dblTaxWages - 1809D)
Case Is <= 2789D
dblTax = 412.39D + 0.25D * (dblTaxWages - 2386D)
Case Is <= 4173D
dblTax = 513.14D + 0.28D * (dblTaxWages - 2789D)
Case Is <= 7335D
dblTax = 900.66D + 0.33D * (dblTaxWages - 4173D)
Case Else
dblTax = 1944.12D + 0.35D * (dblTaxWages - 7335D)
End Select
End If


HELP 2) dblFwt = dblTax (HELP 2 END)



End Sub

Private Sub txtName_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.Enter
' select the existing text

txtName.SelectAll()
End Sub

Private Sub cboAllowances_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cboAllowances.KeyPress
' allow only numbers and the Backspace key

If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub

Private Sub ClearLabels(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstHours.SelectedValueChanged,
lstRate.SelectedValueChanged, radSingle.Click, radMarried.Click, txtName.TextChanged, cboAllowances.TextChanged

lblGross.Text = String.Empty
lblFwt.Text = String.Empty
lblFica.Text = String.Empty
lblNet.Text = String.Empty
End Sub

Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
' verify that the user wants to exit the application

Dim dlgButton As DialogResult
dlgButton =
MessageBox.Show("Do you want to exit?",
"Harvey Industries", MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button1)

' if the No button was selected, don’t close the form
If dlgButton = DialogResult.No Then
e.Cancel = True
End If
End Sub

Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' fills the list boxes with values, then selects a default value

For dblHours As Double = 0 To 55 Step 0.5
lstHours.Items.Add(dblHours.ToString("N1"))
Next dblHours

For dblRates As Double = 7.5 To 15.5 Step 0.5
lstRate.Items.Add(dblRates.ToString("N2"))
Next dblRates

For intAllow As Integer = 0 To 10
cboAllowances.Items.Add(intAllow.ToString)
Next intAllow

lstHours.SelectedItem = "40.0"
lstRate.SelectedItem = "9.50"
cboAllowances.SelectedIndex = 0
End Sub

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

Private Sub btnCalc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalc.Click
' displays gross pay, taxes, and net pay

Const dblFICA_RATE As Double = 0.0765
Dim strStatus As String
Dim dblHours As Double
Dim dblPayRate As Double
Dim intAllowances As Integer
Dim dblGross As Double
Dim dblFwt As Double
Dim dblFica As Double
Dim dblNet As Double

dblHours = Convert.ToDouble(lstHours.SelectedItem.ToString)
dblPayRate = Convert.ToDouble(lstRate.SelectedItem.ToString)
intAllowances = Convert.ToInt32(cboAllowances.Text)

If radSingle.Checked Then
strStatus = "S"
Else
strStatus = "M"
End If

' calculate gross pay
If dblHours <= 40 Then
dblGross = dblHours * dblPayRate
Else
dblGross = 40 * dblPayRate +
(dblHours - 40) * dblPayRate * 1.5
End If

' call a function to calculate the FWT
HELP 3) Call GetFwt(strStatus, intAllowances, dblFwt) HELP 3 END)

' calculate FICA tax
dblFica = dblGross * dblFICA_RATE

' round gross pay, FWT, and FICA tax
dblGross = Math.Round(dblGross, 2)
dblFwt = Math.Round(dblFwt, 2)
dblFica = Math.Round(dblFica, 2)

' calculate net pay
dblNet = dblGross - dblFwt - dblFica

' display calculated amounts
lblGross.Text = dblGross.ToString("N2")
lblFwt.Text = dblFwt.ToString("N2")
lblFica.Text = dblFica.ToString("N2")
lblNet.Text = dblNet.ToString("N2")

End Sub




End Class
Routy
 
Reputation: 0
Posts: 2
Joined: Mon Oct 24, 2011 3:24 am
Highscores: 0
Arcade winning challenges: 0

Private Sub = Call(function) HELP PLEASE - Sponsored results

Sponsored results

Login to get rid of ads

 

^ Back to Top