主题:[讨论]定长或静态数据不能大于64K。局部非静态变量太多
Option Explicit
Private Type a '8 * 10 个字节
a0 As Double
a1 As Double
a2 As Double
a3 As Double
a4 As Double
a5 As Double
a6 As Double
a7 As Double
a8 As Double
a9 As Double
End Type
Private Type b '8 * 10 个字节
b0 As Double
b1 As Double
b2 As Double
b3 As Double
b4 As Double
b5 As Double
b6 As Double
b7 As Double
b8 As Double
b9 As Double
End Type
Private Type c '8 * 10 个字节
c0 As Double
c1 As Double
c2 As Double
c3 As Double
c4 As Double
c5 As Double
c6 As Double
c7 As Double
c8 As Double
c9 As Double
End Type
Private Type d '8 * 10 个字节
d0 As Double
d1 As Double
d2 As Double
d3 As Double
d4 As Double
d5 As Double
d6 As Double
d7 As Double
d8 As Double
d9 As Double
End Type
Private Type m '64KB / 80 Byte /4=204.8,所以全部设置为210,则会超过64K
ma(210) As a
mb(200) As b '如果都改为210,则提示定长或静态数据不能大于64K
mc(200) As c
md(200) As d
End Type
Private Type m1 '使用动态数组,在运行时可以分配大于64K。
ma() As a [color=red]'但这种方式就真的没有限制吗?[/color]
mb() As b
mc() As c
md() As d
End Type
Private Sub Command1_Click()
'Static t As m '定义为静态变量,Ok
'Dim t As m '出现错误:局部,非静态变量太多
Dim t1 As m1 'Ok
ReDim t1.ma(210) As a
ReDim t1.mb(210) As b
ReDim t1.mc(210) As c
ReDim t1.md(210) As d
End Sub
VB里的内存分配时堆、栈的使用是怎样的?请各位大佬指点。。。
Private Type a '8 * 10 个字节
a0 As Double
a1 As Double
a2 As Double
a3 As Double
a4 As Double
a5 As Double
a6 As Double
a7 As Double
a8 As Double
a9 As Double
End Type
Private Type b '8 * 10 个字节
b0 As Double
b1 As Double
b2 As Double
b3 As Double
b4 As Double
b5 As Double
b6 As Double
b7 As Double
b8 As Double
b9 As Double
End Type
Private Type c '8 * 10 个字节
c0 As Double
c1 As Double
c2 As Double
c3 As Double
c4 As Double
c5 As Double
c6 As Double
c7 As Double
c8 As Double
c9 As Double
End Type
Private Type d '8 * 10 个字节
d0 As Double
d1 As Double
d2 As Double
d3 As Double
d4 As Double
d5 As Double
d6 As Double
d7 As Double
d8 As Double
d9 As Double
End Type
Private Type m '64KB / 80 Byte /4=204.8,所以全部设置为210,则会超过64K
ma(210) As a
mb(200) As b '如果都改为210,则提示定长或静态数据不能大于64K
mc(200) As c
md(200) As d
End Type
Private Type m1 '使用动态数组,在运行时可以分配大于64K。
ma() As a [color=red]'但这种方式就真的没有限制吗?[/color]
mb() As b
mc() As c
md() As d
End Type
Private Sub Command1_Click()
'Static t As m '定义为静态变量,Ok
'Dim t As m '出现错误:局部,非静态变量太多
Dim t1 As m1 'Ok
ReDim t1.ma(210) As a
ReDim t1.mb(210) As b
ReDim t1.mc(210) As c
ReDim t1.md(210) As d
End Sub
VB里的内存分配时堆、栈的使用是怎样的?请各位大佬指点。。。