Bryco 发表于 2007-6-28 20:41:11

你能帮我做vb编程吗????

 可以帮我用vb代码吗 我正在使用课堂模块==&燃气轮机;第一类模块:clsClass1选项显式 pName=S结束属性 名称=pName结束属性==&燃气轮机;2st类模块:clsClass2显式选项;如何使类模块的索引类型或也没有数组
&039;例如;clsClass2。索引(0)。名称=“”;请“
&039&nbsp&nbsp&nbsp clsClass2.索引(1)。名称=“”;“帮助”
&039&nbsp&nbsp&nbsp clsClass2。索引(2)。名称=“”;“我”
&039
&039&nbsp msgbox clsClass2。索引(0)。名称(&A)&引用&引用&clsClass2.索引(1)。名称(&A)&引用&引用&clsClass2。索引(2)。名称(&A)&引用&引用
&039
&039;请帮帮我。。。。。

Atook 发表于 2007-6-29 00:15:19

Rainier我不知道你想做什么,但有件事'Class called clsList
Option Explicit
Private StringList(10) As String
Function MakeList() As Variant
    Dim i As Integer
    For i = 0 To 9
      StringList(i) = Str(i) & Chr(i + 64)
    Next i
    MakeList = StringList
End Function模块Option Explicit
Sub Getstring()
    Dim L As New clsList
    Dim i As Integer
    Dim S
    S = L.MakeList
    For i = 0 To UBound(S)
      Debug.Print S(i)
    Next
End Sub

Atook 发表于 2007-6-29 02:44:38

我在vb类模块的一个教程中遇到了一个问题。这个教程很难理解…
如果有人能给我一个最简单的例子,比如我之前发布的带索引或不带索引的类模块;满足“;房地产出租或获得;如果制作了多个对象,请加上索引…
希望有人能帮助…我…给我一个最简单的…提前谢谢…移动电源!!!

Atook 发表于 2007-6-29 13:14:47

我用收藏来做你描述的事情。类似这样的内容:
'local variable to hold collection
Private mCol As Collection
Public Function Add(Size As String, Flow As String, Area As String, Station As String, Precip As String, Optional sKey As String) As clsStation
    'create a new object
    Dim objNewMember As clsStation
    Set objNewMember = New clsStation
    'set the properties passed into the method
    objNewMember.Flow = Flow
    objNewMember.Area = Area
    objNewMember.Station = Station
    objNewMember.Precip = Precip
    objNewMember.Size = Size
    If Len(sKey) = 0 Then
      mCol.Add objNewMember
    Else
      mCol.Add objNewMember, sKey
    End If
    'return the object created
    Set Add = objNewMember
    Set objNewMember = Nothing
End Function
Public Property Get Item(vntIndexKey As Variant) As clsStation
    'used when referencing an element in the collection
    'vntIndexKey contains either the Index or Key to the collection,
    'this is why it is declared as a Variant
    'Syntax: Set foo = x.Item(xyz) or Set foo = x.Item(5)
    On Error Resume Next
    Set Item = Nothing
    Set Item = mCol(vntIndexKey)
End Property
Public Property Get Count() As Long
    'used when retrieving the number of elements in the
    'collection. Syntax: Debug.Print x.Count
    Count = mCol.Count
End Property
Public Sub Remove(vntIndexKey As Variant)
    'used when removing an element from the collection
    'vntIndexKey contains either the Index or Key, which is why
    'it is declared as a Variant
    'Syntax: x.Remove(xyz)
    mCol.Remove vntIndexKey
End Sub
Public Property Get NewEnum() As IUnknown
    'this property allows you to enumerate
    'this collection with the For...Each syntax
    Set NewEnum = mCol.
End Property
Private Sub Class_Initialize()
    'creates the collection when this class is created
    Set mCol = New Collection
End Sub
Private Sub Class_Terminate()
    'destroys collection when this class is terminated
    Set mCol = Nothing
End Sub 我可以想象你可以使用一个数组来保存局部变量,并将属性作为变量。
页: [1]
查看完整版本: 你能帮我做vb编程吗????