passing out of component

Results 1 to 3 of 3

Thread: passing out of component

  1. #1
    ComMan Guest

    Default passing out of component

    I can response.write the info from my com object, but i want to return the value instead.<BR>I&#039;ve tried to pass it out the following, but i keep getting an error.<BR><BR>&#039;&#039;&#039;this gives error<BR>dim ObjReference<BR>Set ObjReference = Server.CreateObject("GrabAResond.Grab")<BR>set aremail = ObjReference.grabarenow<BR>Set ObjReference = Nothing<BR><BR>&#039;&#039;&#039;this works fine..for reponse.write<BR>dim ObjReference<BR>Set ObjReference = Server.CreateObject("GrabAResond.Grab")<BR>ObjRefe rence.grabarenow<BR>Set ObjReference = Nothing<BR><BR>&#039;below is the component code , remember i just want to pass the value out and not response.write it out.<BR><BR>Public Sub grabarenow()<BR> Dim qstr As String<BR> Dim rs As New ADODB.Recordset<BR> Dim sqlstr As String<BR> Dim o_txt As String<BR> <BR> <BR> qstr = MyRequest.QueryString("id")<BR> <BR> If qstr = "" Then<BR> qstr = "LEADERS"<BR> End If<BR> <BR> <BR> sqlstr = "sp_myGetUser &#039;" & qstr_referral & "&#039;"<BR> <BR> rs.Open sqlstr, " Provider=SQLOLEDB.1;Persist Security Info=False;User ID=test;Password=test;Initial Catalog=DEV;Data Source=ONE"<BR> <BR> <BR> If Not rs.EOF And Not rs.BOF Then<BR> o_txt = rs("USER")<BR> Else<BR> End If<BR> <BR> <BR> MyResponse.Write o_txt<BR> &#039; i dont want to write out , instead i want the value so i can use in asp page.<BR> <BR> rs.Close<BR> Set rs = Nothing<BR> <BR>End Sub

  2. #2
    Karin van Ettinger Guest

    Default RE: use properties or a return value

    use a return value <BR><BR>public sub someMethod () as string<BR>&#039; at the end return the value as follows<BR> someMethod = yourString<BR>end sub<BR><BR>In the ASP it looks like<BR> aspString = yourCom.someMethod &#039; if you use a parameter<BR><BR>OR use properties<BR><BR>Public Property Get someString as String<BR> someString = global_string<BR>end property<BR><BR>You need to define the global_string and give it a value in your routine.<BR><BR>In ASP it looks like<BR> yourCom.someMethod &#039; call the method<BR> yourCom.someString &#039; get the property

  3. #3
    Join Date
    Dec 1969

    Default RE: passing out of component

    Redefine your Sub as a Function and return the value thus:<BR><BR>Public Function grabarenow() As String<BR>...<BR>&#039; return the output<BR>grabarenow = o_txt<BR>...<BR><BR>Dunc

Posting Permissions

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