Solved

how do I return an array from classic asp vbscript function

Posted on 2010-09-05
6
970 Views
Last Modified: 2012-05-10
hello EE warriors...

quick question.
How do I return an array from a VBScript function?

See code below:
Function todayslist

    Dim list(3)

    list(0) = "NBC Last Comic Standing"
    list(1) = "ABC Late Night with David Letterman"
    list(2) = "CBS Presidental Speech" 

    dim event1
    dim event2
    dim event3

    event1 = "NBC Last Comic Standing"
    event2 = "ABC Late Night with David Letterman"
    event3 = "CBS Presidental Speech"


    return list


End Function


    Dim todaysevents
    todaysevents = todayslist()
    if todaysevents.count > 0 Then
        Response.write("<ul>")
        For each Item in todaysevents
            Response.write("<li>" + Item)
        Next
        Response.write("/<ul>")
    end if

Open in new window

Function todayslist

    Dim list(3)

    list(0) = "NBC Last Comic Standing"
    list(1) = "ABC Late Night with David Letterman"
    list(2) = "CBS Presidental Speech" 

    dim event1
    dim event2
    dim event3

    event1 = "NBC Last Comic Standing"
    event2 = "ABC Late Night with David Letterman"
    event3 = "CBS Presidental Speech"


    return list


End Function


    Dim todaysevents
    todaysevents = todayslist()
    if todaysevents.count > 0 Then
        Response.write("<ul>")
        For each Item in todaysevents
            Response.write("<li>" + Item)
        Next
        Response.write("/<ul>")
    end if

Open in new window

0
Comment
Question by:Evan Cutler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 55

Expert Comment

by:Bill Prew
ID: 33608548
Try changing

return list

to

todayslist = list

~bp
0
 
LVL 55

Expert Comment

by:Bill Prew
ID: 33608570
Try this.

~bp
Function todayslist
 
    Dim list(3)
 
    list(0) = "NBC Last Comic Standing"
    list(1) = "ABC Late Night with David Letterman"
    list(2) = "CBS Presidental Speech" 
 
    dim event1
    dim event2
    dim event3
 
    event1 = "NBC Last Comic Standing"
    event2 = "ABC Late Night with David Letterman"
    event3 = "CBS Presidental Speech"
 
    todayslist = list
 
End Function
 
    Dim todaysevents
    todaysevents = todayslist()
    if ubound(todaysevents) > 0 Then
        Response.write("<ul>")
        For each Item in todaysevents
            Response.write("<li>" + Item)
        Next
        Response.write("/<ul>")
    end if

Open in new window

0
 
LVL 9

Author Comment

by:Evan Cutler
ID: 33608589
nope.
says object required.

any other ideas?  :)


Thanks
0
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
LVL 55

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 33608600
In my second post, with the ubound() changes, you still got "object required"?

~bp
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 33608607
YOUR AWESOME

Thanks
Evan
0
 
LVL 55

Expert Comment

by:Bill Prew
ID: 33608619
Welcome.  Glad that helped, thanks.

~bp
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question