2010/10/23(Sat) 07:50:52 編集(投稿者)
■No54513 (DD さん) に返信
> 要望通りではありませんが
と書きつつ4を3にする記述わすれてました。
VBFixedArray(4)> と Redimの4は3に変えて下さい。
・・・・
配列拡張構造体を作ってみたので載せておきます。エラーチェックはしてません。
'--- gtyp_Commonはこんな感じで実装してみて下さい。
Public Structure gtyp_Common
<VBFixedString(6), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=7)> Public sAAA As String
<VBFixedString(3), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=4)> Public sBBB As String
<VBFixedString(2), VBFixedArray(3)> Private m_sCCC() As String
Public sCCC As VArray(Of String)
Public Sub Initialize()
sCCC = New VArray(Of String)(m_sCCC, 1, 4)
End Sub
End Structure
'---> ここから下、拡張構造体
Public Structure VArray(Of T)
Implements IVArray, IEnumerable
Private m_ary() As T
Private m_LBound As Integer
Private m_UBound As Integer
Public Sub New(ByRef ary() As T, ByVal Lb As Integer, ByVal Ub As Integer)
m_ary = CType(Array.CreateInstance(GetType(T), Ub - Lb + 1), T())
ary = m_ary
m_LBound = Lb
m_UBound = Ub
End Sub
Default Public Property Item(ByVal idx As Integer) As T
Get
Return m_ary(idx - m_LBound)
End Get
Set(ByVal value As T)
m_ary(idx - m_LBound) = value
End Set
End Property
Public ReadOnly Property Lbound() As Integer Implements IVArray.Lbound
Get
Return m_LBound
End Get
End Property
Public ReadOnly Property UBound() As Integer Implements IVArray.UBound
Get
Return m_UBound
End Get
End Property
Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return m_ary.GetEnumerator
End Function
End Structure
'--- modVArrayの関数用にインターフェース作成
Public Interface IVArray
ReadOnly Property Lbound As Integer
ReadOnly Property UBound As Integer
End Interface
'--- Lbound,Ubound偽装用モジュール
Public Module modVArray
Public Function Lbound(ByVal ary As IVArray) As Integer
Return ary.Lbound
End Function
Public Function UBound(ByVal ary As IVArray) As Integer
Return ary.UBound
End Function
End Module