Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to define a function that returns a string. 1

Status
Not open for further replies.

LikeThisName

Vendor
May 16, 2002
288
US

basically i would like to write a function that returns a string. (a long string)

i need to be able to call my function like this.

response.write myFunction(someInteger)

Code:
function myFunction(myInt as integer) as string
 dim mystring
 mystring =""
 for x=0 to myInt
  mystring = mystring & str(myInt) & vbcrlf
 next
 return mystring
end function

TIA,


LikeThisName <- ? Sorry It's Taken =)
 
Almost right.
vbScript does not support "as"

Code:
function myFunction(myInt)
 dim mystring
 mystring = ""
 for x=0 to myInt
  mystring = mystring & Cstr(myInt) & vbcrlf
 next
 myFunction = mystring
end function

not sure why you would want the vbCrLf in there, as in text myFunction(3) would come out as
0
1
2
3



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
i figured it out almost immediately after i posted it.
thanks though! here is a star.

Chris, what i am actually using it for is i am writing an xml file and i want to call the function to do a database query reading in the myint and the producing the xml tags with the and values returned from the query.

i was just brainlocked and i really appreciate people like you coming to my rescue.

LikeThisName <- ? Sorry It's Taken =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top