943,922 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 709
  • VB.NET RSS
Sep 30th, 2008
0

Badly Stuck

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 2
Junior Poster
laghaterohan is offline Offline
170 posts
since Aug 2008
Sep 30th, 2008
0

Re: Badly Stuck

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
VB.NET Syntax (Toggle Plain Text)
  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
VB.NET Syntax (Toggle Plain Text)
  1. Balance.Text = coursefees - CDbl(installment1.Text)
I hope this will help you
Last edited by manal; Sep 30th, 2008 at 11:48 am.
Reputation Points: 37
Solved Threads: 17
Junior Poster
manal is offline Offline
122 posts
since Mar 2006
Sep 30th, 2008
0

Re: Badly Stuck

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.
vb Syntax (Toggle Plain Text)
  1. If InStr(emailID,"@") > 0 then
  2. emailIDOkay = TRUE
  3. else
  4. emailIDOkay = False
  5. End If
Reputation Points: 27
Solved Threads: 29
Posting Whiz
timothybard is offline Offline
317 posts
since Mar 2007
Sep 30th, 2008
0

Re: Badly Stuck

timothybard is right, just Cdbl won't solve it
Last edited by manal; Sep 30th, 2008 at 12:04 pm.
Reputation Points: 37
Solved Threads: 17
Junior Poster
manal is offline Offline
122 posts
since Mar 2006
Sep 30th, 2008
0

Re: Badly Stuck

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:

VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Oct 1st, 2008
0

Re: Badly Stuck

Oh thanks a lot for your favourable responses !!! I will surely try ur codes....Thanks a lot once again....!

cya
Rohan


Click to Expand / Collapse  Quote originally posted by Teme64 ...
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:

VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 2
Junior Poster
laghaterohan is offline Offline
170 posts
since Aug 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Help usign explorer form...
Next Thread in VB.NET Forum Timeline: [B]setup[/B]





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC