tanveerhabib
Programmer
Hello all i need to mak
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
If salaryAmount >= [b]10600D[/b] The
This is Visual Basic for APPLICATIONS, like Excel, Word, Outlook etc.What application are you coding in?
just want to code a small application in exe...
Private Sub CalculateDisplayAmounts(ByVal salary As Currency)
Dim taxRate As Single
Dim taxAmount As Currency
Dim takeHomePay As Currency
taxRate = GetTaxRate(salary)
taxAmount = salary * taxRate
takeHomePay = salary - taxAmount
'[b]What is the intent here? Seems that you might have a Form?
'So we need LOTS more information from your form here
'not some other code that you copied from.[/b]
'taxRateLabel.Invoke(Sub(x) taxRateLabel.Text = FormatPercent(x), taxRate)
'taxAmountLabel.Invoke(Sub(x) taxAmountLabel.Text = FormatCurrency(x), taxAmount)
'takeHomeLabel.Invoke(Sub(x) takeHomeLabel.Text = FormatCurrency(x), takeHomePay)
End Sub
Private Function GetTaxRate(ByVal salaryAmount As Currency) As Single
Select Case salaryAmount
Case Is > 1000000
GetTaxRate = 0.4
Case Is > 600000
GetTaxRate = 0.25
Case Else
GetTaxRate = 0.15 '[b]I don't know what rate less than 600000???[/b]
End Select
End Function
Sub testit()
Dim salary As Currency
salary = Sheet1.Cells(2, 1).Value
CalculateDisplayAmounts salary
End Sub
Private Sub CalculateDisplayAmounts(ByVal salary As Currency)
Dim taxRate As Single
Dim taxAmount As Currency
Dim takeHomePay As Currency
taxRate = GetTaxRate(salary)
taxAmount = salary * taxRate
takeHomePay = salary - taxAmount
'[b]that is the intent here? Seems that you might have a Form?
'So we need LOTS more information[/b]
'taxRateLabel.Invoke(Sub(x) taxRateLabel.Text = FormatPercent(x), taxRate)
'taxAmountLabel.Invoke(Sub(x) taxAmountLabel.Text = FormatCurrency(x), taxAmount)
'takeHomeLabel.Invoke(Sub(x) takeHomeLabel.Text = FormatCurrency(x), takeHomePay)
'here's your values on Sheet1
With Sheet1
.Cells(1, 1).Value = "Salary"
.Cells(1, 2).Value = "Tax Rate"
.Cells(1, 3).Value = "Tax Amount"
.Cells(1, 4).Value = "Take Home Pay"
.Cells(2, 2).Value = taxRate
.Cells(2, 3).Value = taxAmount
.Cells(2, 4).Value = takeHomePay
End With
End Sub
Private Function GetTaxRate(ByVal salaryAmount As Currency) As Single
Select Case salaryAmount
Case Is > 1000000
GetTaxRate = 0.4
Case Is > 600000
GetTaxRate = 0.25
Case Else
GetTaxRate = 0.15 '[b]I don't know what rate less than 600000???[/b]
End Select
End Function