| | |
Radio buttons and If...Then..If/Else
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 321
Reputation:
Solved Threads: 45
0
#11 Oct 24th, 2009
Seems your are already done with your project. Sorry for the late response, Ive been unable to get back in a timely manner.
Just for your understanding I wanted to point out a few mistakess. First you dont need a double (pun) conversion; you dont need to convert first to a double and then to a decimal. Converting straight to the datatype you want is fine. Second with the Decimal.TryParse method you dont need to convert (cdec()) to a decimal, it will automatically do that for you.
The TryParse has two purposes, first it will automatically convert your value into the variable you provide and second it will return a true/false answer whether it was successfull or not. Lastly you wouldnt want to use Decimal.TryParse to store a value into a datatype of double, in that case either change the variable datatype to a decimal or use a Double.TryParse.
Just for your understanding I wanted to point out a few mistakess. First you dont need a double (pun) conversion; you dont need to convert first to a double and then to a decimal. Converting straight to the datatype you want is fine. Second with the Decimal.TryParse method you dont need to convert (cdec()) to a decimal, it will automatically do that for you.
The TryParse has two purposes, first it will automatically convert your value into the variable you provide and second it will return a true/false answer whether it was successfull or not. Lastly you wouldnt want to use Decimal.TryParse to store a value into a datatype of double, in that case either change the variable datatype to a decimal or use a Double.TryParse.
•
•
•
•
Dim dblHoursUsed As Double ' to hold hours used Dim decAmountDue As Decimal decAmountDue = CDec(CDbl(txtHoursUsed.Text)) ' Check the number of hours used and exit if it contains ' invalid data. If Decimal.TryParse(txtHoursUsed.Text, CDec(dblHoursUsed)) Then lblNumberofHours.Text = "Success!" End If
![]() |
Similar Threads
- Jmail with radio buttons and menus (Site Layout and Usability)
- javascript radio buttons and insanity (JavaScript / DHTML / AJAX)
- dynamically generated textboxes & radio buttons php, insert into db (PHP)
- binding radio buttons (VB.NET)
- javascript: radio buttons (JavaScript / DHTML / AJAX)
- IE6 - dialogue boxes , check boxes and radio buttons work very slowly after hijacking (Viruses, Spyware and other Nasties)
Other Threads in the VB.NET Forum
- Previous Thread: Having a problem with datagrid view and combobox
- Next Thread: CountDown HH:MM:SS Question
Views: 589 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net 2005 2008 access account application arithmetic array arrays basic bing button buttons c# center check checkbox code convert crystalreport data database datagrid datagridview date design designer dissertation dissertations dropdownlist excel fade file-dialog ftp generatetags google gridview hardcopy images inline input insert installer intel internet listview mobile monitor ms net networking objects output passingparameters picturebox picturebox1 port print printing problem project remove save searchbox searchvb.net select serial server shutdown soap sorting studio survey syntax table tcp temperature text textbox time timer toolbox trim update updown user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio2008 web winforms wpf





