Declaring Variables

Results 1 to 3 of 3

Thread: Declaring Variables

  1. #1
    Join Date
    Dec 1969

    Default Declaring Variables

    Hi guys.. I have a question I have the Option Explicit Statement on all of my asp pages so that I make sure to declare every variable. But for some reason I can&#039;t declare any variables inside a function. Is this the way it suppose to be or what do I have to do in order to declare a variable inside a function?<BR><BR>thanks<BR>Carlos

  2. #2
    Join Date
    Dec 1969

    Default RE: Declaring Variables

    Post your code...

  3. #3
    Join Date
    Dec 1969

    Default Agree w/ other poster...

    It definitely SHOULD work.<BR><BR>And, yes, you should be able to use same name as a function-scope variable, even.<BR><BR>Example test page:<BR><BR>********** example.asp **********<BR>&#060;% OPTION Explicit %&#062;<BR><BR>&#060;%<BR>Randomize <BR><BR>Dim test<BR>test = "Page scope test variable"<BR><BR>Function Random( low, high )<BR> Dim test<BR> test = low + Int( (high-low+1) * Rnd() )<BR> Random = "Random number from " & low & " to " & high & " is " & test<BR>End Function<BR><BR>Response.Write "Before: " & test & "&#060;P&#062;"<BR>Response.Write Random( 23, 47 ) & "&#060;P&#062;"<BR>Response.Write "After: " & test & "&#060;P&#062;"<BR>%&#062;<BR><BR>

Posting Permissions

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