redimming my array!

Results 1 to 2 of 2

Thread: redimming my array!

  1. #1
    Join Date
    Dec 1969

    Default redimming my array!

    I&#039;m using MySQL, in case that helps anyone...<BR><BR>I have a scheduling system to book lessons for teachers.<BR><BR>The pupil sees an empty time slot, and wants to book their lesson for this free period.<BR><BR>The next thing I need to do is to randomly allocate the lesson to a free teacher.<BR><BR>I was going to do this:<BR><BR>&#039;******************************* ***<BR><BR>sql002 = sql002 & "SELECT COUNT(fld_id) AS BOB, fld_id, fld_t, "<BR>sql002 = sql002 & "(time_to_sec(fld_time)/1800) as periodnumber FROM appointments "<BR>sql002 = sql002 & "where fld_date = &#039;"&d&"&#039; AND (time_to_sec(fld_time)/1800) = &#039;"&t&"&#039; "<BR>sql002 = sql002 & "AND fld_cat = 2 GROUP BY fld_id"<BR><BR>response.write "<BR>" & sql002<BR><BR>set rs002 = oConn.Execute(sql002)<BR><BR>&#039;get the total number of free teachers for this period<BR>BOB = rs002("BOB")<BR><BR>response.write "BOB: " & BOB & "<BR>"<BR><BR>dim array(BOB)<BR><BR>&#039;--------^ throws up error: Expected integer constant<BR><BR>randomize<BR><BR>x = 1<BR>do while not rs002.eof<BR><BR> array(x) = rs002("fld_t")<BR><BR>rs002.MoveNext<BR>Loop<BR>rs 002.close:set rs002 = nothing<BR><BR>upperbound=ubound(array)<BR>lowerbo und=0<BR>lrandom = Int((upperbound - lowerbound + 1) * rnd + lowerbound)<BR><BR>t_id = Array(lrandom)<BR><BR>sql003 = "insert into appointments (fld_date, fld_time, fld_t, fld_cat) values (&#039;"&d&"&#039;, &#039;"&t&"&#039;, "&t_id&", 1)"<BR><BR>response.write "&#060;HR&#062;" & sql003 & "&#060;HR&#062;"<BR><BR>&#039;******************** ***********<BR><BR>I guess that this is crappy coding as usual for me, since I have obiously passed the array() a non integer, even though if I response.write BOB it is a number. I tried silly things like dim array(int(BOB)) but got the same error.<BR><BR>MSDN said I can&#039;t do what I&#039;m trying to do ( and suggests using the redim option, but I cannot work out how to use it!<BR><BR><BR><BR>Thanks <BR><BR>Jim

  2. #2
    Join Date
    Dec 1969

    Default RE: redimming my array!

    Dim myArray<BR>ReDim myArray(BOB)<BR><BR>********<BR><BR>You can&#039;t use "Array", in any case, as it&#039;s a reserved word in VBS.<BR><BR>And you even used the right terminology in your message subject:<BR> REDIMming<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