vb.net - Try Catch for displaying input error messages -
Hey I'm new to using the dictionary in VB.Net and trying to figure out how to try check the appropriate variable type is known about the use of the catch, as is not leaving empty entries about the hard work I'm confused, is an error handling message to the user. I hold it in every key and variable that is output right.
For example, would not be like to
dim dblTravel = new dictionary (string of, double) dblTravel. ( "Travel_Days", CDbl (txtTravelDays.Text)) dblTravel.Add ( "Private_Vehicle_Miles", CDbl (txtPrivateVehicleMiles.Text)) dblTravel.Add ( "Lodging_Per_Night", CDbl (txtLodgingPerNight.Text)) dblTravel.Add (Add "Travel_Total" , nothing) dim dblExpenses = new dictionary (string, double) dblExpenses.Add ( "airfare", CDbl (txtAirfare.Text)) dblExpenses.Add ( "Car_Rental_Fees", CDbl (txtCarRentalFees.Text)) dblExpenses. Add ( "Parking_Fees", CDbl (txtParkingFees.Text)) dblExpenses.Add ( "Taxi_Charges", CDbl (txtTaxiCharges.Text)) dblExpenses.Add ( "Registration_Fees", CDbl (txtRegistationFees.Text)) dblExpenses.Add ( "food" , CDbl (txtMeals.text)) These are my two dictionary variables that are with their index keys. I am a bit Both would like to include to catch up with another type every key value which is not the correct data type or NULL value, I want it to output an error message to the user.
Example output
- Travel days should be a numeric value
- Airfare should be a numeric value
- Taxi charge free Can not be
This type of error should be displayed in the message to record and handling the error for the user. In the example output, they are an example of two errors with the output display, for which I would like to check.
Thanks for taking a look in advance, hope you can help.
try / hold the original data is slightly overkill for verification. Use this to understand that when you can not understand what might be wrong - you have already followed the user input to the rules so that you should know what to check.
Click on the button event:
sub ok_click (....) as decimal decimal if Integer.TryParse as dim travelDays integer Money dim TaxiFare (tbTravelDays.Text, travelDays) is a double base = false than double overkill is too dim airfare as decimal then contents of the control can not be converted to an integer value. 'Complain to the user; MessageBox.Show has passed 'TryParse then exit', so the trips are a valid integer 'You may also want to check that it is not negative! End if decimals if TRPRS (TBTC. Text, taxifare) = If incorrect, the contents of the control can not be converted into decimal values. 'Complain to the user; MessageBox.Show then exit again other 'also passes' your 'no empty' rule probably means that they have to enter a number, end if if everything OK (data valid) those variables will have values entered with them, then the next:
Process to add values and AddValuesToDictionary (travel, airfare, taxifire) to them You have to fiddle with some things - your dictionary Currently (string, double) is, I think it Bdlunga in decimal, only a singularity is TravelDays , which is possibly a int .
Do you know do know that your dictionary will place a (1) entry for any key (such as "Travelage")? If you are trying to gather values for many employees, then each person will be bombarded with their own travel costs.
Comments
Post a Comment