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: TomW is on a distinguished road 
Solved Threads: 45
TomW TomW is offline Offline
Posting Whiz
 
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.

Originally Posted by jess99 View Post
   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
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 17
Reputation: jess99 is an unknown quantity at this point 
Solved Threads: 0
jess99 jess99 is offline Offline
Newbie Poster
 
0
  #12
Oct 24th, 2009
Thank you, Tom. I have three more programs to write. I am reading about class and objects. I used and object (Me.) and TextBox1 as property for the first assignment. Now, I am working in program 2 of the assignment.

Thanks again
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 590 | Replies: 11
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC