Variable in a sub routine

Results 1 to 3 of 3

Thread: Variable in a sub routine

  1. #1
    Join Date
    Dec 1969
    Posts
    5

    Default Variable in a sub routine

    I am trying to use a variable in a subroutine without success. I am passing a table named "EU". segStr is a global variable that for this example may contain "FL,Floor", so in this case I am trying to read EU-&#062;Floor.<BR><BR>Sub NX(tbname)<BR> segArray = split(segStr, ",")<BR> For i = 0 to ubound(segArray) step 2<BR> &#039; this is a test and will write EU and EU-&#062;Floor value<BR> &#039; Response.write tbname & eu(segArray(i+1)) <BR> &#039; but if I test with<BR> &#039; Response.write tbname & tbname(segArray(i+1))<BR> &#039; I get this error -- Type mismatch: &#039;tbname&#039; <BR> &#039; and, of course, same error on next line which is not a test<BR> if len(trim(tbname(segArray(i+1)))) &#062; 0 then<BR> mvar = mvar & "NX" & segArray(i) & "~" & segArray(i+1)<BR> segcnt = segcnt + 1<BR> end if<BR>Next<BR>End Sub <BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    464

    Default RE: Variable in a sub routine

    k the type mismatch error means that tbname isnt an array or a function... so it shouldnt have parenthesis after it... Unless you are meaning to pass an array into tbname... I assumed you were passing the string "EU". Try to figure out whats going on with your syntax.....<BR><BR>Btw after you fix the error you should send this function to one of those "Unreadable code contests". I write unreadable code too so its all good. Teaches you how to debug well :p.

  3. #3
    Join Date
    Dec 1969
    Posts
    5

    Default RE: Variable in a sub routine

    Thanks for your reply, I think. I was passing the parameter with parens, removing them did the trick. Sorry about code. I am a Cold Fusion developer trying to quickly convert a CF app to ASP. Next time I will just ask the question and leave the code off. :)<BR><BR>Thanks again<BR>Rich

Posting Permissions

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