乐筑天下

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

你能帮我在我的vb proging吗????

[复制链接]

2

主题

11

帖子

1

银币

初来乍到

Rank: 1

铜币
19
发表于 2007-6-28 20:41:11 | 显示全部楼层 |阅读模式
能帮我写vb代码吗??我正在使用类模块….
希望有人能帮助我…我是类模块的初学者….
=>第一类模块:clsClass1
选项显式
私有pName作为字符串
属性让Name(S作为字符串)
pName=S
结束属性<br>属性Get Name()作为字符串<br>Name=pName
终止属性<br>=>2st类模块:clsClass2<br>选项显式<br>'要创建类、模块或无数组的索引类型
,例如clsClass2.索引(0)。name=“please”
“clsClass2.索引(1)。name=“help”
“clsClass2.index(2)。name=“me”

”msgbox-clsClass2.index(0)。名称&clsClass2.index(1)。名称&clsClass2.index(2)。姓名:&“…”

”请帮助我。。。。。

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 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

回复

使用道具 举报

2

主题

11

帖子

1

银币

初来乍到

Rank: 1

铜币
19
发表于 2007-6-29 02:44:38 | 显示全部楼层
我在vb类模块的教程中遇到了一个问题...教程很难理解...
如果有人能给我一个最简单的类模块示例,无论是否有索引,就像我之前发布的那样...满足“属性let or get”加上索引,如果制作了多个对象...
希望有人能帮忙...我...给我一个最简单的...提前感谢...移动电源!!!
回复

使用道具 举报

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 18:48 , Processed in 0.614544 second(s), 61 queries .

© 2020-2025 乐筑天下

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