乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 48|回复: 3

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

[复制链接]

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2007-6-28 20:41:11 | 显示全部楼层 |阅读模式
 可以帮我用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;请帮帮我。。。。。
回复

使用道具 举报

85

主题

404

帖子

7

银币

中流砥柱

Rank: 25

铜币
751
发表于 2007-6-29 00:15:19 | 显示全部楼层
Rainier我不知道你想做什么,但有件事
  1. 'Class called clsList
  2. Option Explicit
  3. Private StringList(10) As String
  4. Function MakeList() As Variant
  5.     Dim i As Integer
  6.     For i = 0 To 9
  7.         StringList(i) = Str(i) & Chr(i + 64)
  8.     Next i
  9.     MakeList = StringList
  10. End Function
模块
  1. Option Explicit
  2. Sub Getstring()
  3.     Dim L As New clsList
  4.     Dim i As Integer
  5.     Dim S
  6.     S = L.MakeList
  7.     For i = 0 To UBound(S)
  8.         Debug.Print S(i)
  9.     Next
  10. End Sub
回复

使用道具 举报

85

主题

404

帖子

7

银币

中流砥柱

Rank: 25

铜币
751
发表于 2007-6-29 02:44:38 | 显示全部楼层
我在vb类模块的一个教程中遇到了一个问题。这个教程很难理解…
如果有人能给我一个最简单的例子,比如我之前发布的带索引或不带索引的类模块;满足“;房地产出租或获得;如果制作了多个对象,请加上索引…
希望有人能帮助…我…给我一个最简单的…提前谢谢…移动电源!!!
回复

使用道具 举报

85

主题

404

帖子

7

银币

中流砥柱

Rank: 25

铜币
751
发表于 2007-6-29 13:14:47 | 显示全部楼层
我用收藏来做你描述的事情。类似这样的内容:
  1. 'local variable to hold collection
  2. Private mCol As Collection
  3. Public Function Add(Size As String, Flow As String, Area As String, Station As String, Precip As String, Optional sKey As String) As clsStation
  4.     'create a new object
  5.     Dim objNewMember As clsStation
  6.     Set objNewMember = New clsStation
  7.     'set the properties passed into the method
  8.     objNewMember.Flow = Flow
  9.     objNewMember.Area = Area
  10.     objNewMember.Station = Station
  11.     objNewMember.Precip = Precip
  12.     objNewMember.Size = Size
  13.     If Len(sKey) = 0 Then
  14.         mCol.Add objNewMember
  15.     Else
  16.         mCol.Add objNewMember, sKey
  17.     End If
  18.     'return the object created
  19.     Set Add = objNewMember
  20.     Set objNewMember = Nothing
  21. End Function
  22. Public Property Get Item(vntIndexKey As Variant) As clsStation
  23.     'used when referencing an element in the collection
  24.     'vntIndexKey contains either the Index or Key to the collection,
  25.     'this is why it is declared as a Variant
  26.     'Syntax: Set foo = x.Item(xyz) or Set foo = x.Item(5)
  27.     On Error Resume Next
  28.     Set Item = Nothing
  29.     Set Item = mCol(vntIndexKey)
  30. End Property
  31. Public Property Get Count() As Long
  32.     'used when retrieving the number of elements in the
  33.     'collection. Syntax: Debug.Print x.Count
  34.     Count = mCol.Count
  35. End Property
  36. Public Sub Remove(vntIndexKey As Variant)
  37.     'used when removing an element from the collection
  38.     'vntIndexKey contains either the Index or Key, which is why
  39.     'it is declared as a Variant
  40.     'Syntax: x.Remove(xyz)
  41.     mCol.Remove vntIndexKey
  42. End Sub
  43. Public Property Get NewEnum() As IUnknown
  44.     'this property allows you to enumerate
  45.     'this collection with the For...Each syntax
  46.     Set NewEnum = mCol.[_NewEnum]
  47. End Property
  48. Private Sub Class_Initialize()
  49.     'creates the collection when this class is created
  50.     Set mCol = New Collection
  51. End Sub
  52. Private Sub Class_Terminate()
  53.     'destroys collection when this class is terminated
  54.     Set mCol = Nothing
  55. End Sub
我可以想象你可以使用一个数组来保存局部变量,并将属性作为变量。
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 19:14 , Processed in 1.105960 second(s), 60 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表