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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling an object from another function of another class

Status
Not open for further replies.

mchoudhury

Programmer
Nov 26, 2004
71
GB
I created a class in vb.net in that class i have a function within that function there is an object. In another asp.net front end web form i'm trying to retrive that object from that class but not sure how to.
Does anyone knows how this could take place.

Class name - CostPerMonth
Function - getCostPermonth
Object to retrive- Dim FinalTotal As Single

i have imported the namespace. but how can i retrive the object.

Thanks
 
Here's a simple example that might help you:

Class:
Code:
Public Class _MyClass
    Public MyObject As Single

    Public Function MyFunction()
        MyObject = 5
    End Function
End Class

Web Page:
Code:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim MyNewClass As New _MyClass
        MyNewClass.MyFunction()
        Dim MyNewObject As Single = MyNewClass.MyObject
    End Sub

Hope this helps.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Thank you its working perfectly - just one more question on the aspx front web page how will i write this object so it shows up when the page load.
at present i'm doing it like this -
CPM.getCostPerMonth(TC, TM)
Dim Total As Single = CPM.FinalTotal
Response.Write(Total)

but i know there is another way of retrving this value to the fron end web code its somethin like this <%%>.
 
Using <% %> tags is the classic ASP way of writing to the page and you would include the response.write inside those tags.

I would suggest using a label and setting the text property of the label to the Total.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top