VB.Net InputBox validation negative number - vb.net

I'm working on a program for a user to input a number in an InputBox. I could write the codes to validate the input value is numeric, but I couldn't came up with a procedure to validate the negative number from InputBox.
Dim UserInput As String = ""
Dim UserInputAsNumber As Integer
Dim SumofTotal As Integer
'to display InputBox
UserInput = (InputBox("Enter a positive number", "Input Needed"))
'to capture userinput is not numeric value
While (Not IsNumeric(UserInput))
UserInput = (InputBox("Enter a positive number", "Input Needed"))
End While
'if userinput is number, convert the value to numeric variable
UserInputAsNumber = CInt(UserInput)
If (UserInputAsNumber <= 0) Then
UserInput = (InputBox("Enter a positive number", "Input Needed"))
Else
SumofTotal = CInt(((UserInputAsNumber * (UserInputAsNumber + 1)) / 2))
'calculation
End If
MessageBox.Show("The sum is " & CStr(SumofTotal))
End Sub

You need to loop through your code until you get a valid positive integer. You can simplify things by using Integer.TryParse to validate the string and convert it to an integer (invalid strings will convert to zero).
Private Sub btnEnterNumbers_Click(sender As Object, e As EventArgs) Handles btnEnterNumbers.Click
Dim UserInput As String = ""
Dim UserInputAsNumber As Integer
Dim SumofTotal As Integer
Do While UserInputAsNumber <= 0
'to display InputBox
UserInput = (InputBox("Enter a positive integer value", "Input Needed", "10"))
'convert to integer, will be zero if not valid integer
Integer.TryParse(UserInput, UserInputAsNumber)
Loop
' Gauss formula to calculate the total of a sequence of numbers from userinput
SumofTotal = CInt(UserInputAsNumber * (UserInputAsNumber + 1) / 2)
MessageBox.Show("The sum of the numbers 1 through " & CStr(UserInputAsNumber) & " is " & CStr(SumofTotal))
End Sub

Related

Only accept Integer values from InputBox VB.Net within Do While Loop

I'm trying to figure out why my program is accepting non-integer values which it then converts to an integer by rounding. The first value the user enters is validated, however, the rest isn't. My program is meant to count the number of odd and even integer numbers the user has entered. Any help would be greatly appreciated.
Private Sub btnShow_Click(sender As System.Object, e As System.EventArgs) Handles btnAddNum.Click
Dim intInputNum As Integer
Dim strInputNum As String = ""
Dim isEven As Integer = 0
Dim isOdd As Integer = 0
Dim userInput As String = InputBox(("Enter a number (0 to end)"))
Dim numArray() As String = strInputNum.Split(New Char() {","c})
Dim validInput As Boolean = Integer.TryParse(userInput, intInputNum)
If validInput = False Then
MsgBox("Invalid input, integer numbers only")
ElseIf validInput = True Then
Do While intInputNum > 0 And validInput = True
If intInputNum Mod 2 = 0 And validInput = True Then
lblEvenValues.Text = lblEvenValues.Text & CStr(intInputNum) & ","
intInputNum = Val(InputBox("Enter a number (0 to end)"))
isEven = isEven + 1
lblCountEven.Text = isEven
ElseIf intInputNum Mod 2 <> 0 And validInput = True Then
lblOddValues.Text = lblOddValues.Text & CStr(intInputNum) & ","
intInputNum = Val(InputBox("Enter a number (0 to end)"))
isOdd = isOdd + 1
lblCountOdd.Text = isOdd
ElseIf validInput = False Then
MsgBox("Invalid input, integer numbers only")
End If
Loop
End If
End Sub
This line:
Do While intInputNum > 0
is causing you issues. When the user inputs a non-integer value, after the first loop, this line: Val(InputBox("Enter a number (0 to end)")) evaluates to zero.
Which is obviously not greater than 0.
Reuse your boolean statement to evaluate userInput, not intInputNum like so:
userInput = Val(InputBox("Enter a number (0 to end)"))
validInput = Integer.TryParse(userInput, intInputNum)
Then you need to fix your message box location to simply show up outside of your loop rather than in it. So when validInput <> True it will break the loop and output your Msgbox.
You will also need to fix your Do While statement to correctly evaluate userInput instead of intInputNum

How to don't allow the user to enter an amount of more than 100

I have this case where I need that the user enters some data. All I need is to allow the user to enter numbers from 0 to 100, if the user is entering an amount bigger than 100, than display a message like: please enter number from 0 to 100 and then show them again where they need to enter that number.
For example, Console.Write("Español: ") in the terminal is:
Español: ' the user should enter the number here
if the user enters more than 100, then display this:
Please enter number from 0 to 100. Español: ' here enter the number again
I was thinking on doing this as in the code below, with an If ... Else, but, is there a better way?
Here is the actual code:
Sub Main()
Dim Español1 As Integer
Dim Matematicas1 As Integer
Dim Ciencias1 As Integer
Dim EstudiosSociales1 As Integer
Dim Ingles1 As Integer
Dim ArtesPlasticas1 As Integer
Dim ArtesIndustriales1 As Integer
Select Case Menu
Case 2
Console.Write("Ingrese las notas: ")
Console.ReadLine()
Console.Write("Español: ")
' I was thinking on doing this
If Console.ReadLine() >= 100 Then
Console.Write("La nota debe ser 100 o menos: ")
Español1 = Console.ReadLine()
Else
Español1 = Console.ReadLine()
End If
If Español1 = True Then
Console.Write("Matematicas: ")
Matematicas1 = Console.ReadLine()
End If
Console.Write("Ciencias: ")
Ciencias1 = Console.ReadLine()
Console.Write("Estudios Sociales: ")
EstudiosSociales1 = Console.ReadLine()
Console.Write("Ingles: ")
Ingles1 = Console.ReadLine()
Console.Write("Artes plasticas: ")
ArtesPlasticas1 = Console.ReadLine()
Console.Write("Artes Industriales: ")
ArtesIndustriales1 = Console.ReadLine()
Console.Clear()
End Select
End Sub
So, any suggestions?
I'm not really experienced with VB, but try this:
Dim n as Integer
n = Console.WriteLine()
Do While n >= 100
Console.WiteLine("Enter new Value:") 'Sorry, no pienso la lengua español :(
n = Console.ReadLine()
Loop
Edit 3.0
Add your subject names into the array subjects.
Sub Main()
Dim subjects As Array = {"Math", "English", "German"} 'Three example names
Dim subjectsInt As New Dictionary(Of String, Integer)
Dim i, input As Integer
Dim check, FirstTry As Boolean
For i = 0 To (subjects.Length - 1)
check = False
FirstTry = True
Do
If FirstTry = True Then
Console.WriteLine(subjects(i) & ": ")
FirstTry = False
Else
Console.WriteLine("Please enter a value between 1 and 100" & " (" & subjects(i) & "):")
End If
input = Console.ReadLine()
If input <= 100 And input > 0 Then
subjectsInt.Add(subjects(i), input)
check = True
End If
Loop While check = False
Next
For i = 0 To (subjects.Length - 1)
Console.WriteLine(subjects(i) & ": " & subjectsInt(subjects(i)))
Next
Console.ReadLine()
End Sub
Well I dont know VBA unfortunately . But I believe in every language is the same. You do a do {}while cycle and in the while you check if you conditions are met. And until they are met you continue reading from the console. Good look with your VBA :)

Assignment Guidance

This is the third week of my intro to programming class and I'm stuck. I can get it to run I just can't enter more than 1 number. This is a vb console app.
Module Module1
Sub Main()
Dim highestNumber As Integer = -1000000000
Dim lowestNumber As Integer = 100000000
Dim userInput As Integer
Console.WriteLine("Input your numbers and when you are done enter -99.")
Console.WriteLine("The app will then give the highest and lowest numbers entered.")
userInput = Console.ReadLine()
While userInput <> "-99"
If userInput >= highestNumber Then
highestNumber = userInput
ElseIf userInput <= lowestNumber Then
lowestNumber = userInput
End If
End While
Console.WriteLine("The highest number you entered is: " & highestNumber)
Console.WriteLine("The lowest number you entered is: " & lowestNumber)
Console.ReadLine()
End Sub
End Module
You're only executing ReadLine once, before the loop starts, so you only get to enter one number. As it currently stands, if you don't enter -99 then you have an infinite loop since you cannot change userInput inside the loop.
You need to put a copy of userInput = Console.ReadLine() at the end of the While loop so that a new value can be entered and the logic will be re-executed.
Also, you might as well remove the = signs from your tests. No point changing the highest/lowest unless the new number is actual higher/lower.
Move this line inside your while loop
userInput = Console.ReadLine()
Here's my solution. It checks the input of the user, if it's not an integer they can try again or enter -99 and get out... You can also change how many numbers a user enters by changing a few places where it shows 2, or declare a variable and set it and then use it...
Public Sub Main()
Dim userInput As Integer = 0
Dim lstInteger As New List(Of Integer)
Console.WriteLine("Input your numbers and when you are done enter -99." & Environment.NewLine & "The app will then give the highest and lowest numbers entered.")
Do Until userInput = -99
If Integer.TryParse(Console.ReadLine(),userInput) AndAlso userInput <> -99 Then
lstInteger.Add(userInput)
If lstInteger.Count = 2 Then Exit Do
userInput = 0
If Integer.TryParse(Console.ReadLine(), userInput) AndAlso userInput <> -99 Then
lstInteger.Add(userInput)
If lstInteger.Count = 2 Then Exit Do
Else
If userInput = -99 Then Exit Do Else Console.WriteLine("Please enter a number.")
End If
Else
If userInput <> - 99 AndAlso userInput = 0 Then
Console.WriteLine("Please enter a number.")
Else
Exit Do
End If
End If
Loop
If lstInteger.Count = 2 Then
Console.WriteLine("The highest number you entered is: " & lstInteger.Max.ToString)
Console.WriteLine("The lowest number you entered is: " & lstInteger.Min.ToString)
End If
Console.ReadLine()
End Sub

Variable won't change

I'm trying to finish a project for class that calculates the occupancy rate of a hotel using an InputBox object. However, the variables are getting permanently set as the first value entered.
Allow me to clarify what is happening. I click the button to bring up the InputBox I enter a number e.g. 10, then I click ok, then I enter a new number for the second one e.g. 7, but the list box displays both as the first one. Once I enter all the numbers for the Rooms Sold I then continue to enter the values for Rooms Available, but the number form the first loop somehow carried over to the second one and WILL NOT change.
What can I do to make it so the variable is reset for each iteration of the loop. I have it set the variable back to 0 after it has added itself to the total and the list, but it won't change.
And i did do research. The MSDN knowledge base was no help, I could only find one question on here like this and he just forgot to define a string, and I tried Google but to no avail.
Here is my code:
Public Class frmOccupancyRateCalculator
Private Sub frmOccupancyRateCalculator_Load(sender As Object, e As EventArgs) Handles MyBase.Load
lstRoomsSold.Items.Clear()
lstRoomsAvailable.Items.Clear()
End Sub
Private Sub btnEnterRoomSales_Click(sender As Object, e As EventArgs) Handles btnEnterRoomSales.Click
' Declare the arithimetic and message variables.
Dim intRoomsSold As Integer
Dim intRoomsAvailable As Integer
Dim intTotalRooms As Integer
Dim intTotalRoomsSold As Integer
Dim intTotalRoomsAvailable As Integer
Dim intRoomsSoldNumberOfEntries As Integer = 1
Dim intRoomsAvailableNumberOfEntries As Integer = 1
Dim intNumberOfEntries As Integer = 1
Dim intMaxNumberOfEntries As Integer = 7
Dim decOccupancyRate As Decimal
Dim strRoomsSold As String
Dim strRoomsSoldInputMessage As String = "Enter the number of rooms sold for floor #"
Dim strRoomsSoldInputHeading As String = "Enter Rooms Sold"
Dim strRoomsSoldNormalMessage As String = "Enter the number of rooms sold for floor #"
Dim strRoomsSoldNonNumericError As String = "Error - Non-Numeric value entered. Please enter a whole number of rooms sold for floor #"
Dim strRoomsSoldNegativeError As String = "Error - Negative number entered. Please enter a whole number greater than zero of rooms sold for floor #"
Dim strRoomsSoldDecimalError As String = "Error - Decimal number entered. Plerase enter a whole number of rooms sold for floor #"
Dim strRoomsAvailable As String
Dim strRoomsAvailableInputMessage As String = "Enter the number of rooms available for floor #"
Dim strRoomsAvailableInputHeading As String = "Enter Rooms Available"
Dim strRoomsAvailableNormalMessage As String = "Enter the number of rooms available for floor #"
Dim strRoomsAvailableNonNumericError As String = "Error - Non-Numeric value entered. Please enter a whole number of rooms available for floor #"
Dim strRoomsAvailableNegativeError As String = "Error - Negative number entered. Please enter a whole number greater than zero of rooms available for floor #"
Dim strRoomsAvailableDecimalError As String = "Error - Decimal number entered. Plerase enter a whole number of rooms available for floor #"
Dim strCancelClicked As String = ""
' Define the RoomsSoldInputMessage variables
strRoomsSold = InputBox(strRoomsSoldInputMessage & intRoomsSoldNumberOfEntries, strRoomsSoldInputHeading, " ")
' Loop to iterate until hours of travel are entered for all days of travel
Do Until intRoomsSoldNumberOfEntries > intMaxNumberOfEntries
' Is the input numeric?
If IsNumeric(strRoomsSold) Then
intRoomsSold = Convert.ToDecimal(strRoomsSold)
' Is the input greater or equal to 0?
If intRoomsSold >= 0 Then
' Is the number of rooms sold a whole number?
'If intRoomsSold Mod 1 = 0 Then
intTotalRoomsSold += intRoomsSold
lstRoomsSold.Items.Add(intRoomsSold)
intRoomsSoldNumberOfEntries += 1
intRoomsSold = 0
strRoomsSoldInputMessage = strRoomsSoldNormalMessage
' Display decimal error message
'Else
'strRoomsSoldInputMessage = strRoomsSoldDecimalError
'End If
' Display negative number error message
Else
strRoomsSoldInputMessage = strRoomsSoldNegativeError
End If
' Display non-numeric error message
Else
strRoomsSoldInputMessage = strRoomsSoldNonNumericError
End If
' Is the number of entries less than or equal to the maximum?
If intRoomsSoldNumberOfEntries <= intMaxNumberOfEntries Then
strRoomsSoldInputMessage = InputBox(strRoomsSoldInputMessage & intRoomsSoldNumberOfEntries, strRoomsSoldInputHeading, " ")
End If
Loop
' Define the RoomsAvailableInputMessage variable
strRoomsAvailable = InputBox(strRoomsAvailableInputMessage & intRoomsAvailableNumberOfEntries, strRoomsAvailableInputHeading, " ")
Do Until intRoomsAvailableNumberOfEntries > intMaxNumberOfEntries
' Is the input numeric?
If IsNumeric(strRoomsAvailable) Then
intRoomsAvailable = Convert.ToDecimal(strRoomsAvailable)
' Is the input greater or equal to 0?
If intRoomsAvailable >= 0 Then
' Is the number of rooms sold a whole number?
'If intRoomsAvailable Mod 1 = 0 Then
intTotalRoomsAvailable += intRoomsAvailable
lstRoomsAvailable.Items.Add(intRoomsAvailable)
intRoomsAvailableNumberOfEntries += 1
intRoomsAvailable = 0
strRoomsAvailableInputMessage = strRoomsAvailableNormalMessage
' Is the number of entries equal to the maximum number of entries?
If intRoomsAvailableNumberOfEntries = intMaxNumberOfEntries Then
intNumberOfEntries += 1
End If
' Display decimal error message
'Else
' strRoomsAvailableInputMessage = strRoomsAvailableDecimalError
' End If
' Display negative number error message
Else
strRoomsAvailableInputMessage = strRoomsAvailableNegativeError
End If
' Display non-numeric error message
Else
strRoomsAvailableInputMessage = strRoomsAvailableNonNumericError
End If
' Is the number of entries less than or equal to the maximum?
If intRoomsAvailableNumberOfEntries <= intMaxNumberOfEntries Then
strRoomsAvailableInputMessage = InputBox(strRoomsAvailableInputMessage & intRoomsAvailableNumberOfEntries, strRoomsAvailableInputHeading, " ")
End If
Loop
' Is the number of rooms sold entries greater than 1?
If intNumberOfEntries > 1 Then
' Display result label and totals
intTotalRooms = intTotalRoomsSold + intTotalRoomsAvailable
decOccupancyRate = intTotalRoomsSold / intTotalRooms
lblResult.Visible = True
lblResult.Text = intTotalRooms & vbNewLine & intTotalRoomsSold & vbNewLine & intTotalRoomsAvailable & vbNewLine & vbNewLine & decOccupancyRate.ToString("P")
' Disable the Enter Room Sales button
btnEnterRoomSales.Enabled = False
' Display error message for no values entered
Else
MsgBox("No Rooms Sold/Available value entered")
End If
End Sub
Private Sub mnuClear_Click(sender As Object, e As EventArgs) Handles mnuClear.Click
' This script is executed when the user taps or clicks the Clear menu item.
' It clears the Room Sales and Rooms Available ListBoxes, hides the Result label,
' enables the Enter Room Sales button.
lstRoomsSold.Items.Clear()
lstRoomsAvailable.Items.Clear()
lblResult.Visible = False
btnEnterRoomSales.Enabled = True
End Sub
Private Sub mnuExit_Click(sender As Object, e As EventArgs) Handles mnuExit.Click
' This script is executed when the user taps or clicks the Exit menu item.
' The window is closed and the program is terminated.
Close()
End Sub
End Class
Ok I figured it out. I needed to put the strRoomsSold and strRoomsAvailable variable definitions within the loops, then remove the second sequence within the Do Until loop.
' Loop to iterate until Rooms Sold number of Entries is greater than the maximum
Do Until intRoomsSoldNumberOfEntries > intMaxNumberOfEntries
' Define the RoomsSold variable
strRoomsSold = InputBox(strRoomsSoldInputMessage & intRoomsSoldNumberOfEntries, strRoomsSoldInputHeading, " ")
If strRoomsSold = strCancelClicked Then
strRoomsSoldInputMessage = strRoomsAvailableBlankError
Else
' Is the input numeric?
If IsNumeric(strRoomsSold) Then
intRoomsSold = Convert.ToDecimal(strRoomsSold)
' Is the input greater or equal to 0?
If intRoomsSold >= 0 Then
' Is the number of rooms sold a whole number?
If intRoomsSold Mod 1 = 0 Then
intTotalRoomsSold += intRoomsSold
lstRoomsSold.Items.Add(intRoomsSold)
intRoomsSoldNumberOfEntries += 1
strRoomsSoldInputMessage = strRoomsSoldNormalMessage
' Display decimal error message
Else
strRoomsSoldInputMessage = strRoomsSoldDecimalError
End If
' Display negative number error message
Else
strRoomsSoldInputMessage = strRoomsSoldNegativeError
End If
' Display non-numeric error message
Else
strRoomsSoldInputMessage = strRoomsSoldNonNumericError
End If
End If
Loop
Do Until intRoomsAvailableNumberOfEntries > intMaxNumberOfEntries
' Define the RoomsAvailable variable
strRoomsAvailable = InputBox(strRoomsAvailableInputMessage & intRoomsAvailableNumberOfEntries, strRoomsAvailableInputHeading, " ")
' Is the input numeric?
If IsNumeric(strRoomsAvailable) Then
intRoomsAvailable = Convert.ToDecimal(strRoomsAvailable)
' Is the input greater or equal to 0?
If intRoomsAvailable >= 0 Then
' Is the number of rooms sold a whole number?
If intRoomsAvailable Mod 1 = 0 Then
intTotalRoomsAvailable += intRoomsAvailable
lstRoomsAvailable.Items.Add(intRoomsAvailable)
intRoomsAvailableNumberOfEntries += 1
strRoomsAvailableInputMessage = strRoomsAvailableNormalMessage
' Is the number of entries equal to the maximum number of entries?
If intRoomsAvailableNumberOfEntries = intMaxNumberOfEntries Then
intNumberOfEntries += 1
End If
' Display decimal error message
Else
strRoomsAvailableInputMessage = strRoomsAvailableDecimalError
End If
' Display negative number error message
Else
strRoomsAvailableInputMessage = strRoomsAvailableNegativeError
End If
' Display non-numeric error message
Else
strRoomsAvailableInputMessage = strRoomsAvailableNonNumericError
End If
Loop

VB.net: Input string not correct format?

Hey guys I have been having this crashing problem with my program.
I am trying to create a program where it calculates a persons account balance by inputting their beginning balance, credit limit, total charges, and total credits. In this case I am having specific problems with the Total Charges and Total Credits Code.
I have a message box set up to where if the Total Charges and total credits box are blank it will say "please enter a numeric value for ....". The problem is that when I do run it and enter a blank, the message shows up and then the program crashes.
After crashing, the The program then highlights in yellow the specific conversion code (in this case: decTotalCharges = Convert.ToDecimal(txtTotalCharges.Text)) and the error says Input string was not in correct format.
What's going on, I converted it into a correct format right? (decimal to decimal?). Here's an in depth look at my code:
Public Class frmEndingBalance
'Declare module level variables
Dim mdecEndingBalance As Decimal
Dim mdecAllCharges As Decimal
Dim mdecAllCredits As Decimal
Dim mintCustomersOverLimit As Integer
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
'clears the form
'clears the labels
txtAccountNumber.Text = ""
txtBeginningBalance.Text = ""
txtTotalCharges.Text = ""
txtTotalCredits.Text = ""
txtCreditLimit.Text = ""
lblEndingBalance.Text = ""
lblCreditMessage.Text = ""
lblAllCharges.Text = ""
lblAllCredits.Text = ""
lblCustomersOverLimit.Text = ""
lblCreditMessage.Text = ""
'clear the textboxes
txtAccountNumber.Clear()
txtBeginningBalance.Clear()
txtTotalCredits.Clear()
txtTotalCharges.Clear()
txtCreditLimit.Clear()
'clear module level variables
mdecEndingBalance = 0
mdecAllCharges = 0
mdecAllCredits = 0
mintCustomersOverLimit = 0
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
'Declare Variables
Dim intAccountNumber As Integer
Dim intBeginningBalance As Integer
Dim decTotalCharges As Decimal
Dim decTotalCredits As Decimal
Dim decCreditLimit As Decimal
Dim mdecEndingBalance As Decimal 'Beginning Balance + Charges - Credits()
Dim decCreditMessage As Decimal
'check for numeric
If IsNumeric(txtAccountNumber.Text) = False Then 'value is not numeric
MessageBox.Show("You can't enter anything blank!")
Exit Sub
End If
'convert to a numeric data type
intAccountNumber = Convert.ToInt32(txtAccountNumber.Text)
'check for numeric
If String.IsNullOrEmpty(txtBeginningBalance.Text) Then MessageBox.Show("Beginning Balance Cannot Be Blank!")
'check for everything else
If IsNumeric(txtBeginningBalance.Text) = False Then 'Value is not numeric
MessageBox.Show("Please enter a numeric value for Beginning Balance!")
Exit Sub
End If
'convert to a numeric data type
intBeginningBalance = Convert.ToInt32(txtBeginningBalance.Text)
'check for numeric
If IsNumeric(txtTotalCharges.Text) = False Then 'value is not numeric
MessageBox.Show("Please enter a numeric value for Total Charges!")
End If
'convert
decTotalCharges = Convert.ToDecimal(txtTotalCharges.Text)
'check for 0 or positive
If decTotalCharges < 0 Then
MessageBox.Show("Please enter a positive value or zero for number of Total Charges!")
Exit Sub
End If
'check for numeric
If IsNumeric(txtTotalCredits.Text) = False Then 'value is not numeric
MessageBox.Show("Please enter a numeric value for Total Credits")
End If
'convert to a numeric data type
decTotalCredits = Convert.ToDecimal(txtTotalCredits.Text)
'check for 0 or positive
If decTotalCredits < 0 Then
MessageBox.Show("Please enter a positive value or zero for total credits!")
End If
'check numeric
If IsNumeric(txtCreditLimit.Text) = False Then 'value is not numeric
MessageBox.Show("Please enter a numeric value for the Credit Limit!")
End If
'convert to a numeric data type
decCreditLimit = Convert.ToDecimal(txtCreditLimit.Text)
'check for a 0 or positive
If decCreditLimit < 0 Then
MessageBox.Show("Please enter a positive value or zero for Credit Limit!")
End If
'check for customers over limit
decCreditMessage = decCreditLimit - (mdecEndingBalance)
'running totals
mdecAllCharges += decTotalCharges
mdecAllCredits += decTotalCredits
'calculate Ending Balance
mdecEndingBalance = Convert.ToDecimal(intBeginningBalance + decTotalCharges - (decTotalCredits))
'display outputs
lblEndingBalance.Text = mdecEndingBalance.ToString("c")
lblAllCharges.Text = mdecAllCharges.ToString("c")
lblAllCredits.Text = mdecAllCredits.ToString("c")
lblCustomersOverLimit.Text = mintCustomersOverLimit.ToString("n0")
End Class
Any Help would be greatly appreciated!
Thanks
You've missed Exit Sub out of the test
If IsNumeric(txtTotalCharges.Text) = False Then 'value is not numeric
MessageBox.Show("Please enter a numeric value for Total Charges!")
End If
You've done it in a few other places as well (as have we all , in fact as do we all :( ). Be worth refactoring with a little helper method or something similar.
If IsValidDecimal(txtTotalCharges.Text, "Total Charges")
' etc
End If