Wrox Home  
 
Search P2P Archive for  go

More Wrox Resources

  Return to Index  

asp_web_howto thread: how to Assign an object to a variable


Message #1 by "dee" <drexton@h...> on Tue, 22 Jan 2002 16:07:12
I would like to know if it is possible to set a object to a variable with 

a function, using the variable name as the argument.

I ussually do this by having a global variable name and then having a 

argumentless functioncall set the object to the global variable name. This 

works fine but it dosent seem the best way below is an example of how i 

would like to do it.

but this dosent work thought.

Is it possible if so how?????



sub main()

  dim flsObj

  call fsobject(flsObj) 

  'now flsObj should be an object but isnt

end sub



sub fsobject(byref flsObj)

 if isobject(flsObj) = true then exit function

 'now i want to set the variable supplied to an object

 set  flsObj = createobject("scripting.filesystemobject")	

end sub
Message #2 by "Alfredo Yong" <alfredo_yong_linux@h...> on Tue, 22 Jan 2002 11:42:38 -0500
I use a  function to get my conection object. The object is created within

the function and returned as function value. You could pass the object as

argument, test if IsObject then  return just the already existent object:



Function EstablishConnection(variable)

Dim conActual



If     IsObject(variable) then

    Set EstablishConnection = variable

Else

     Set conActual = Server.CreateObject("ADODB.Connection")

     conActual.open "nalp", "sa",""

     Set EstablishConnection = conActual

End If



End Function



greetings,

Alfredo.



dee <drexton@h...> escribió en el mensaje de noticias

138273@a..._web_howto...

>

> I would like to know if it is possible to set a object to a variable with

> a function, using the variable name as the argument.

> I ussually do this by having a global variable name and then having a

> argumentless functioncall set the object to the global variable name. This

> works fine but it dosent seem the best way below is an example of how i

> would like to do it.

> but this dosent work thought.

> Is it possible if so how?????

>

> sub main()

>   dim flsObj

>   call fsobject(flsObj)

>   'now flsObj should be an object but isnt

> end sub

>

> sub fsobject(byref flsObj)

>  if isobject(flsObj) = true then exit function

>  'now i want to set the variable supplied to an object

>  set  flsObj = createobject("scripting.filesystemobject")

> end sub

>

>





Message #3 by "dee" <drexton@h...> on Tue, 22 Jan 2002 17:33:57
Thanks Alfredo for your solution but i would like to know if it is 

possible to actualy do it the way i suggested. 

I want to explicitly send a variable name byreference and then set that 

variable within a function.



If it where possible i would like to know

  Return to Index