Public Type GB5782_Type
螺纹规格 As String
e As Double
S As Double
K As Double
End Type Dim GB5782Array(13) As Variant
GB5782Array(0) = Array("M5", 8.63, 8, 3.5)
GB5782Array(1) = Array("M6", 10.89, 10, 4)
问题提出
GB5782Data.螺纹规格 = GB5782Array(ii)(0)'这样赋值比较麻烦
能否有一种方法,让GB5782Array引入如(ii)的方法.
实现GB5782Data.螺纹规格(ii希望的方法) = GB5782Array(ii)(0)
请教各位大侠这种方法能实现吗??
螺纹规格 As String
e As Double
S As Double
K As Double
End Type Dim GB5782Array(13) As Variant
GB5782Array(0) = Array("M5", 8.63, 8, 3.5)
GB5782Array(1) = Array("M6", 10.89, 10, 4)
问题提出
GB5782Data.螺纹规格 = GB5782Array(ii)(0)'这样赋值比较麻烦
能否有一种方法,让GB5782Array引入如(ii)的方法.
实现GB5782Data.螺纹规格(ii希望的方法) = GB5782Array(ii)(0)
请教各位大侠这种方法能实现吗??
Option ExplicitPrivate Type GB5782_Type
螺纹规格 As String
e As Double
S As Double
K As Double
End Type
Private Sub Command1_Click()
Dim GB5782Array(13) As GB5782_Type
GB5782Array(0).螺纹规格 = "M5"
GB5782Array(0).e = 8
GB5782Array(0).S = 8.63
GB5782Array(0).e = 3.5
GB5782Array(1).螺纹规格 = "M6"
GB5782Array(1).e = 10
GB5782Array(1).S = 10.89
GB5782Array(1).e = 4
' GB5782Array(0). = Array("M5", 8.63, 8, 3.5)
' GB5782Array(1) = Array("M6", 10.89, 10, 4)
End Sub
'以下代码在窗体中
Option Explicit
Private Sub Command1_Click()
Dim A1 As New GB5782
A1.螺纹规格 = "M5"
A1.e = 8
A1.S = 8.69
A1.K = 3.5
Dim A2 As New clsGB
A2.Add A1, "M5"
MsgBox A2.GBData("M5").螺纹规格
End Sub'以下代码在类中:
'类名: clsGB
Option ExplicitDim newControl As New Collection
Public Function Add(ByVal DataInfo As GB5782, Optional ByVal key As String)
If Len(key) = 0 And Not IsNumeric(key) Then
newControl.Add DataInfo
Else
newControl.Add DataInfo, key
End If
End Function
Public Property Get GBData(ByVal Index As Variant) As GB5782
Set GBData = newControl.Item(Index)
End Property'以下代码在类中:
'类名: GB5782Option Explicit Public 螺纹规格 As String
Public e As Double
Public S As Double
Public K As Double
[/code]
mm = "螺纹规格""GB5782Data" & Chr(34) & "螺纹规格" 能赋值
实现GB5782Data.再与mm结合 等价于 GB5782Data.螺纹规格的目的.
Callbyname
吧.
也许也起到意想不到的效果.比如取得文本框的属性.msgbox CallbyName( Text1,"Text",vbGet)