English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i have a class file (eg class1.vb) in my project/App_Code folder

how to use variables and method tat i defined in the class1.vb file?

what should i do?

2007-02-28 18:53:57 · 2 answers · asked by jchris 3 in Computers & Internet Programming & Design

2 answers

If it is an external class,I mean it is in a external file : you should right click on your project name on the solution explorer panel , choose add a refrence.
A window will be opened,then choose your dll or exe file.

If it's not an external file just use it, I mean type the code given below at the top of your source code:
using namespace.class;

namespace>>namespace of your code scope
class>>the name of your class

2007-02-28 21:59:52 · answer #1 · answered by Moein 3 · 0 0

Public Class class1
private _var1 As string
Public Property var1() As string
Get
return _var1
End Get
Set(ByVal value As String)
_var1 = value
end set
End Property

Public Function calculateArea(ByVal length As Double, ByVal width As double) As Double
private area As String
area = length*width
return area
End Function

End Class

'That was class1. Now the class from which we want to reference class1

Public Class class2
private _var2 As String
private _area As Double
private _width As Double
private _length As Double

'Declare here the properties var2, width, length and area like in class1, but pay attention to types!
Private Sub doSomething()
var2 = class1.var1
area = class1.calculateArea(length, width)
End Sub
End Class

2007-03-01 03:17:34 · answer #2 · answered by Rumtscho 3 · 0 1

fedest.com, questions and answers