| | |
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: 590 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access advanced application array basic beginner browser button buttons center class click client code combo convert cuesent data database datagrid datagridview date datetimepicker design designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function html images lib listview map mobile module msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read refresh regex richtextbox right-to-left save search serial settings shutdown socket sorting sqldatbase sqlserver studio temperature textbox timer timespan transparency txttoxmlconverter usercontol validation vb vb.net vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms winsock wpf wrapingcode xml year





