Jump to content
Sign in to follow this  
smus

How to check if a string is empty

Recommended Posts

How do we check if a given string is empty or not? I've tried isNull, isEmpty as well as equal and non-equal signs, the results are the same for empty and filled texts.
My code looks like this:
 

Call am(es)
Call am(fs)

es = ""
fs = "ms"

Sub am(s)
 if s <> "" then
  response.write "The string is not empty <br>"
 else
  response.write "The string is empty <br>"
 end if
end Sub

 

Share this post


Link to post
Share on other sites

That looks fine but you should probably declare your variables before you try to use them.

  • Thanks 1

Share this post


Link to post
Share on other sites
On 9/10/2018 at 11:30 PM, justsomeguy said:

That looks fine but you should probably declare your variables before you try to use them.

Added Dim es, fs but the result is the same. "The string is empty" for both cases

Share this post


Link to post
Share on other sites

You're calling the subroutine passing in variables that have not been initialized. Initialize the variables first, then call the subroutine. 

  • Thanks 1

Share this post


Link to post
Share on other sites
3 minutes ago, Ingolme said:

You're calling the subroutine passing in variables that have not been initialized. Initialize the variables first, then call the subroutine. 

Right, thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×