Results 1 to 2 of 2

Thread: Dynamically building statements

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    94

    Dynamically building statements

    Hi guys,

    How can I rewrite this so that it is dynamic? That is, I want there to be a variable number of elements with the q# entries going from 1 to #...

    decimal[] vals = new decimal[7];
    vals[0] = Convert.ToDecimal (context.Request["q1"]);
    vals[1] = Convert.ToDecimal (context.Request["q2"]);
    vals[2] = Convert.ToDecimal (context.Request["q3"]);
    vals[3] = Convert.ToDecimal (context.Request["q4"]);
    vals[4] = Convert.ToDecimal (context.Request["q5"]);
    vals[5] = Convert.ToDecimal (context.Request["q6"]);
    vals[6] = Convert.ToDecimal (context.Request["q7"]);

    Thanx in advance!

  2. #2
    Lively Member
    Join Date
    Jan 2001
    Location
    Worcester, MA
    Posts
    77
    not sure what language you are using but I would assume you could use some sort of an array.

    Code:
    for i = 0 to #
    vals[i] = Convert.ToDecimal (context.Request["q" & i+1 & "]);
    next
    something like that maybee
    "Find all you need in your mind if you take the time" -DT

Posting Permissions

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



Click Here to Expand Forum to Full Width