Problem with zero length values...

# Thread: Problem with zero length values...

1. Senior Member
Join Date
Dec 1969
Posts
433

## Problem with zero length values...

Ok,<BR><BR>Someone kindly gave me this function (changed a little)<BR><BR>I am feeding it data from a form. However one of the main purposes of this error checking is to check for empty fields.<BR><BR>This is a problem due to the fact that it won&#039;t accept zero length values... :o(<BR><BR>Function LoadValue(FormValue) <BR>IF Len(Trim(FormValue)) &#062; 0 THEN<BR>LoadValue = Trim(FormValue) <BR>ELSE<BR>ErrorCount = ErrorCount + 1 <BR>END IF<BR>End Function <BR><BR><BR>Anyone got any ideas?<BR><BR>I am feeding it data like:<BR><BR>variablename=LoadValue(Request.Form(" formelementname"))

2. Senior Member
Join Date
Dec 1969
Posts
1,765

I think I just got deadlocked with you!

3. Senior Member
Join Date
Dec 1969
Posts
1,765

## I don't think I follow what you want vs what

I don&#039;t think I follow what you want vs what you have

4. Senior Member
Join Date
Dec 1969
Posts
1,944

## RE: Problem with zero length values...

JUST ADD ANOTHER ELSE IF STATEMENT AS BELOW TO HANDLE ZERO LENGTH STRINGS<BR><BR>Function LoadValue(FormValue) <BR>IF Len(Trim(FormValue)) &#062; 0 THEN <BR>LoadValue = Trim(FormValue) <BR>ELSEIF Len(Trim(FormValue)) = 0 THEN <BR>&#039;do whatever you like&#039;<BR>ELSE<BR>ErrorCount = ErrorCount + 1 <BR>END IF <BR>End Function

5. Senior Member
Join Date
Dec 1969
Posts
1,944

## and actually

after the check for zero length values, the else<BR>condition doesn&#039;t make sense, since you can&#039;t get strings with<BR>less than zero length

6. Senior Member
Join Date
Dec 1969
Posts
433

## The problem here is...

That I can&#039;t feed a zero length to the function as there is actually nothing being fed to it. I need to know if there is a way I can.

7. Senior Member
Join Date
Dec 1969
Posts
1,570

## RE: The problem here is...

You don&#039;t need to send it into a function. The if statment is so basic, that it could easily just be done inside the code. It would definetly be able to send in and test zero-length variables...

8. Senior Member
Join Date
Dec 1969
Posts
433

## Oh balls. <eop>

It&#039;s ok. I&#039;ve found out what I was doing wrong. :o)

9. Member
Join Date
Dec 1969
Posts
55

## RE: Oh balls. <eop>

Share the solution? I&#039;m curious.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•