By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,632 Members | 1,425 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,632 IT Pros & Developers. It's quick & easy.

Help with VB 2005 with message box

P: 1
Assignment is to have user enter days in pay period with starting pay as a penny and then doubled for each day. Restriction of 19 days minimum and 22 days maximum for pay period. Want to have an error message if user enters a non numeric, negative number or days outside allowed range (19 - 22)

Had it working when only had error for number of days in range but needed to add the other 2 error messages. When I added them the clear and exit controls in the menu don’t work.

As written – if I enter a number between 19 and 22 – it works fine
If I enter a non numeric I first get the message need to enter a numeric number, then the enter a number between 19 and 22 comes up. The clear and exit doesn’t wor

Here is the code – appreciate the help
Private Sub radPenny_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles radPenny.Click
'Declare variables
Dim strDaysEntered As String
Dim intDaysEntered As Integer
Dim dblFirstDayPay As Double = 0.01
Dim intDays As Integer

'Did user enter a numeric value?
If IsNumeric(Me.txtDaysInPayPeriod.Text) Then
intDaysEntered = Convert.ToInt32(Me.txtDaysInPayPeriod.Text)
If intDaysEntered > 0 Then
intDaysEntered = Convert.ToInt32(Me.txtDaysInPayPeriod.Text)
MessageBox.Show("Enter a Number Greater than Zero.", "Input Error")
Me.txtDaysInPayPeriod.Text = ""
End If
MessageBox.Show("Enter a Numeric Value.", "Input Error")
Me.txtDaysInPayPeriod.Text = ""
End If

If Me.txtDaysInPayPeriod.Text = "19" Or Me.txtDaysInPayPeriod.Text = "20" _
Or Me.txtDaysInPayPeriod.Text = "21" Or Me.txtDaysInPayPeriod.Text = "22" Then
strDaysEntered = Me.txtDaysInPayPeriod.Text
intDaysEntered = Convert.ToInt32(Me.txtDaysInPayPeriod.Text)
Else : MsgBox("Enter number of days paid between 19 and 22", , "ERROR")
End If

'Initialize loop variable
intDays = 1

Do Until intDays = intDaysEntered
dblFirstDayPay = dblFirstDayPay * 2
intDays = intDays + 1

Me.lblCalculatedAmount.Text = dblFirstDayPay.ToString("C")

End Sub
Nov 29 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.