Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2004, 08:28 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to Replace Null Values???

Hello Guyz...!

I`ve the following code:
----------
months1 = Request.Form("txtmonths")
months = replace(months1," ","0")
----------
but it`s not working. I guess that the problem is that months1 is a null value. So... what to do?

The only solution is to check if the value is null and then set it to "0"????
 
Old October 6th, 2004, 09:19 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

Use this code.

If(Not(IsNull(months1))) then
    replace(months1," ","0")
Else
    months1="00"
End If

----------------------------------------------------

To have a better solution, please give some more detail about your particular programming context.
 
Old October 6th, 2004, 09:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Varg_88,

What is that you are trying to achieve?

What value does "months1" contain when NOT NULL? Can you post some real data for that here? What you want it to contain if NULL or otherwise.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 7th, 2004, 01:59 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your replies...!

I`ve got a textbox where the user should put a value from 0 to 11 (this is the months values). But also I`ve give the ability to the user when he inserts "no value" in this textbox I want "0" value to be inserted into the db automatically. I hope that you can understand me now.

I found the solution with the following code:
-------
if months1 = ""
then months = 0
else
months = months1
--------
But I think that there must be a more clever way to achieve this. :)

Thank you again for your replies!
 
Old October 7th, 2004, 02:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Your solution is right though. Otherwise you can check this way that is more safer.;)
Code:
If len(months1)>0 and IsNaN(months1) and cint(months1) > 0  then 
    months = months1
else
    months = 0
End If
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 7th, 2004, 02:28 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

You can use a select box with 12 options (values going from 1 to 12). Then make the selection of some entry in it mandatory. Or make one of them selected by default.

If you are using a text box, you will have to do a number of validations. People can enter <space>0, space<1> etc. which should go correct. Then you will have to trap other characters etc.

If there are only 12 options for the select box (with values going from 1 to 12), you don't need any validation. One value from this will always be selected.

--------------------------------------------------------------------------
ps. You have to do some basic authentication works as below.
The action page for the form containing the above select box should check whether the posting has come from the correct website. Otherwise, people can copy the form from the source, change the select box as they wish, add more options and then submit by giving the full path of action page. You have to avoid this.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to handle null values imaginevictor ASP.NET 1.x and 2.0 Application Design 1 March 20th, 2007 01:52 AM
Null values jmcgranahan BOOK: Access 2003 VBA Programmer's Reference 0 August 29th, 2006 02:25 PM
Catching NULL values hasanali00 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 July 1st, 2005 10:29 PM
Checking for Null Values asmodeus BOOK: Beginning VB.NET Databases 2 June 3rd, 2005 03:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.