Testing for variables

Results 1 to 3 of 3

Thread: Testing for variables

  1. #1
    Linda Guest

    Default Testing for variables

    Can anyone tell me how I can test for the existence of variables using asp? I have been using mainly Cold Fusion and use the "IsDefined" function regularly. <BR><BR>Thanks in advance

  2. #2
    lagerBoy Guest

    Default RE: Testing for variables

    Use the IsEmpty() function.<BR><BR>For example:<BR><BR>Dim a<BR><BR>Response.Write IsEmpty(a)<BR><BR>This will return a boolean - True. Whereas:<BR><BR>Dim a<BR>a = 1<BR><BR>Response.Write IsEmpty(a)<BR><BR>This will return a boolean - False. So you could use IsEmpty() as a test in an If...Then statement like so:<BR><BR><BR>If IsEmpty(a) Then<BR> &#039a is empty<BR>.<BR>.<BR>.<BR>Else<BR> &#039a is not empty<BR>.<BR>.<BR>.<BR>End If<BR><BR><BR>

  3. #3
    Joel N Guest

    Default RE: Testing for variables

    ASP doesn&#039t throw and error if you request a value that doesn&#039t exist like CF does. If you do something like this:<BR><BR>&#060;%<BR>dim x<BR>x = Request.Form("aVariableName")<BR>%&#062;<BR><BR>an d there was no variable named "aVariableName" then x will hold an empty string.

Posting Permissions

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