When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs



















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

New Media Specialist
Aquent
US-CO-Denver

Justtechjobs.com Post A Job | Post A Resume

Don't skimp on the variables!


  • Back to Intermediate Developer's Tip Index
  • Next tip...

    Now, you might be wondering, what does he mean, Don't skimp on the variables? Well, often times it is more efficient to use variables to store results from ADO queries or from objects, and then reference the variable as opposed to continuously referencing the object.

    For example, you could do this:

    If Request.QueryString("Name") = "Frank" Then
       ...
    End If

    If Request.QueryString("Name") = "Steve" Then
       ...
    End If

    Response.Write("Your name is " & Request.QueryString("Name"))

    Each time you use the Request object, ASP has to go read the QueryString variable name. You can reduce this to having to just read this once by doing the following:

    Dim strName
    strName = Request.QueryString("Name")

    If strName = "Frank" Then
       ...
    End If

    If strName = "Steve" Then
       ...
    End If

    Response.Write("Your name is " & strName)

    Plus, I personally think the above scenario is easier to read. It's easier, I think, to mentally associate strName to be the user's name as opposed to associating Request.QueryString("Name") as the user's name. Just my two cents, though!

  • Back to Intermediate Developer's Tip Index
  • Next Tip...


    Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article

  • internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info

    Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers