vb点虐 创建类 vbnet adodb

vb点虐 如何在一个项目中创建类,并且使用他?

在任意form类或模块中都可以创建类,跟建立函数和过程一样。

成都创新互联专注于梁园企业网站建设,响应式网站建设,商城系统网站开发。梁园网站建设公司,为梁园等地区提供建站服务。全流程定制网站制作,专业设计,全程项目跟踪,成都创新互联专业和态度为您提供的服务

示例:

public class form1

‘创建一个属于form的子类,名称为【类名】。

public class 类名

’定义类成员text

public text as string

end class

‘定义一个【类名】类的公共变量。

dim 类名1 as 类名

’定义一个过程,使用【类名】类的text成员

public sub 过程

‘实例化【类名1】

类名1=new 类名

类名1.text=“赋值”

’定义一个【新类】类的私用变量,并实例化。

dim 新类1 as new 新类

新类1.name=“一个字符串”

新类1.age=12

end sub

end class

‘’‘创建一个与form同级的类,名称为【新类】

public class 新类

public sub new()

end sub

public name as string

public age as integer

end class

在模块中使用:

public class module1

dim a as new form1.类名

end module

vb点虐 中创建类

不熟悉VB,如有不妥的地方请包涵!

Public Class Stack

Dim aryData() As Integer

Sub New(ByVal Num As Integer)

Dim aryData(Num) As Integer

End Sub

Function Pop() As Integer

If (aryData.Length = 0) Then

Return 0

Else

Dim a As Integer

a = aryData(aryData.Length)

aryData(aryData.Length) = Convert.ToInt32(DBNull.Value)

Return a

End If

End Function

Sub Push(ByVal n As Integer)

For Each i As Integer In aryData

If (aryData(i) = Convert.ToInt32(DBNull.Value)) Then

aryData(i) = n

End

Else

Continue For

End If

Next

End Sub

Sub PrintStack()

For Each i As Integer In aryData

If (aryData(i) = Convert.ToInt32(DBNull.Value)) Then

End

Else

Print(aryData(i))

End If

Next

End Sub

End Class

vb点虐 创建类引用类

你是指……

Dim 变量名 as 类型 = new 类型(构造参数)

这样么

或者是

Dim 变量名 as new 类型(构造参数)

这样?

还是说

Class 类名

End Class

这样?


当前文章:vb点虐 创建类 vbnet adodb
转载源于:http://pwwzsj.com/article/ddesjcj.html