|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ok. code below. have one page with one text box where user enters a balance(number). then they are forced to click an html image (MUST be this way per boss) which takes them to another page that makes calculations. works fine if they actually enter a number. however, if they fail to enter anything and click the image link, i get a "type mismatch" error. if they do this, i need my var(balance) to equal 0. can anyone help me? so new to all of this. thanks.
balance = request("balance") if balance <> "" Then totalnew = balance + 3000 + (balance * .025) formula1 = .0125 / 12 payment = totalnew * (formula1 / (1 - (1 + formula1) ^ -360)) year1 = FormatCurrency(payment) year2 = FormatCurrency(year1 * 0.075 + year1) year3 = FormatCurrency(year2 * 0.075 + year2) year4 = FormatCurrency(year3 * 0.075 + year3) year5 = FormatCurrency(year4 * 0.075 + year4) else balance = 0 year1 = 0 year2 = 0 year3 = 0 year4 = 0 year5 = 0 end if |
|
#2
|
|||
|
|||
|
You could always try using cint around balance: cint(balance).
One other thing, I assume your grabing balance from a querystring or from a form on the previous page, with that being said I usually set it up in this fashion but this is personal preference only: session("variableName") = request("variableName") variableName = session("variableName") Again just person preference. |
|
#3
|
|||
|
|||
|
thanks but i am not sure that helps me
let me explain further:
index.html has one text box in a form, one submit button and an "apply now" gif that is a hyperlink to "calculate.asp". if the user enters say, 100,000 into the text box and presses the submit form button, then the var(balance) has 100,000 as its value. if the user then presses the gif hyperlink, calculate.asp is displayed and all is well. IF however no value is entered AND submitted on index.html, and the user presses the gif hyperlink, a type mismatch error occurs on the var(balance) and calculate.asp doesn't work. the server returns an error. essentially i need to idiot-proof this thing so if a user does NOT enter a value, calculate.asp STILL loads with var(balance) equal to 0. i have tried a simple balance = 0 before the request("balance") but that doesn't work. thanks again |
|
#4
|
|||
|
|||
|
i havent read all the thread, but i see a potential problem right away. try request.form("balance")
|
|
#5
|
|||
|
|||
|
if xtremcoder's advice doesn't solve your problem could you attach your html page and that asp page so I could see all of your code.
|
|
#6
|
|||
|
|||
|
thank. xtremcoder did it for me
appreciate ALL your help everyone!
you are all great |
|
#7
|
|||
|
|||
|
any time...
|
|
#8
|
|||
|
|||
|
you might be able to do this by:
dim balance if request.form("balance")="" then balance="0" else balance=request.form("balance") end if |
|
#9
|
|||
|
|||
|
if isNumeric(Request.Form("Balance")) then
balance = cint(request.form("Balance")) else balance = 0 end if |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > DESPERATE help with IF statement needed |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|