Badly Stuck

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2008
Posts: 126
Reputation: laghaterohan is an unknown quantity at this point 
Solved Threads: 1
laghaterohan laghaterohan is offline Offline
Junior Poster

Badly Stuck

 
0
  #1
Sep 30th, 2008
pl.help me out on this :
i need to calculate balance amount....however...i am not able to calculate it.
C i have coursefees

then when i click on installment 1 and enter the amount my balance amount textbox should reflect
the coursefees- installment1 total

similarly when i click on installment 2 and enter the amount my balance amt textbox should reflect
the coursefees-inst1-inst2 value

similarly when i click on intallment 3 and enter the amount my balance amt textbox should reflect
the coursefees -inst1-inst2-inst3

however i am getting error as cannot convert string "" to double...! i tired a lot but i am not
getting over this error ! Pl help me out soon !

waiting for quick response!

2) can ne one tell me how to validate email id text box....
eg..if @ sign is missing it should prompt(Invalid email id!)

cya
Rohan
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 121
Reputation: manal is an unknown quantity at this point 
Solved Threads: 17
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: Badly Stuck

 
0
  #2
Sep 30th, 2008
it would be better if you post your code
any way , I think you didn't convert from string to double before calculating,
you wrote like this
  1. Balance.Text = coursefees - installment1.Text
it may work but if user did not enter value and leave the textbox empty then you will have cannot convert string "" to double error
to solve it
  1. Balance.Text = coursefees - CDbl(installment1.Text)
I hope this will help you
Last edited by manal; Sep 30th, 2008 at 11:48 am.
"give only what u willing to receive "
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 306
Reputation: timothybard is an unknown quantity at this point 
Solved Threads: 26
timothybard's Avatar
timothybard timothybard is offline Offline
Posting Whiz

Re: Badly Stuck

 
0
  #3
Sep 30th, 2008
The problem you are having concerning "cannot convert string "" to double" is that you have an empty textbox. You need to add code so that if a textbox is blank, then the program does not try to perform a calculation on it. Better yet, add some validation to make sure the text is a number.

For item number two, use the instr() command to see if the "@" character is in the e-mail address. i.e.
  1. If InStr(emailID,"@") > 0 then
  2. emailIDOkay = TRUE
  3. else
  4. emailIDOkay = False
  5. End If
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 121
Reputation: manal is an unknown quantity at this point 
Solved Threads: 17
manal's Avatar
manal manal is offline Offline
Junior Poster

Re: Badly Stuck

 
0
  #4
Sep 30th, 2008
timothybard is right, just Cdbl won't solve it
Last edited by manal; Sep 30th, 2008 at 12:04 pm.
"give only what u willing to receive "
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Badly Stuck

 
0
  #5
Sep 30th, 2008
Here's a link to test for a valid email address with regular expression:
http://www.vbforums.com/showthread.php?t=407441
and you should also check:
http://www.regular-expressions.info/email.html
and you'll notice that there's not any bullet-proof method to test email address validity.

Manal answered your first question, but here's a slightly improved version:

  1. If String.IsNullOrEmpty(installment1.Text) Then
  2. ' Empty value
  3. Balance.Text = ""
  4. Else
  5. Try
  6. Balance.Text = (coursefees - CDbl(installment1.Text)).ToString
  7. Catch ex As Exception
  8. ' installment1.Text was not a numerical value
  9. Balance.Text = ""
  10. End Try
  11. End If
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 126
Reputation: laghaterohan is an unknown quantity at this point 
Solved Threads: 1
laghaterohan laghaterohan is offline Offline
Junior Poster

Re: Badly Stuck

 
0
  #6
Oct 1st, 2008
Oh thanks a lot for your favourable responses !!! I will surely try ur codes....Thanks a lot once again....!

cya
Rohan


Originally Posted by Teme64 View Post
Here's a link to test for a valid email address with regular expression:
http://www.vbforums.com/showthread.php?t=407441
and you should also check:
http://www.regular-expressions.info/email.html
and you'll notice that there's not any bullet-proof method to test email address validity.

Manal answered your first question, but here's a slightly improved version:

  1. If String.IsNullOrEmpty(installment1.Text) Then
  2. ' Empty value
  3. Balance.Text = ""
  4. Else
  5. Try
  6. Balance.Text = (coursefees - CDbl(installment1.Text)).ToString
  7. Catch ex As Exception
  8. ' installment1.Text was not a numerical value
  9. Balance.Text = ""
  10. End Try
  11. End If
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC