.


:




:

































 

 

 

 


.




, VBA eval(), JavaScript, , , , .

, , . , .

. fragm:

Public name As String, val As Integer

Private Sub Class_Initialize()

name = "f" & Int(Rnd * 10000) ' f567

val = Rnd * 20 + 10 ' 10 30

End Sub

Dim cl_f As New Collection

Private Sub UserForm_Initialize()

Dim f As fragm, i As Integer

Randomize

For i = 1 To 10

Set f = New fragm

cl_f.Add f, f.name

ListBox1.AddItem f.name

Next

End Sub

.

Private Sub ListBox1_Click()

MsgBox cl_f(ListBox1.List(ListBox1.ListIndex)).val

End Sub

VBE . . ThisDocument, , , , . . CodeModule , . , , .

1 ( ). changecode, . Chr(34) .

Sub try()

j = 2: ns = 11

With VBE.VBProjects(1).VBComponents(j).CodeModule

.DeleteLines ns, 1

.InsertLines ns, "MsgBox " & Chr(34) & "22222" & Chr(34)

End With

changcode

End Sub

 

Sub changcode()

MsgBox "11111"

End Sub

, , , . , . - .. , .

ReDim. , , :

Dim () [As type]

, , . , . :

ReDim () [As type]

. :

[ to] , [ to] ,

. , ( ) Option Base.

Option base 1 ' = 1.

Dim Lower

Dim MyArray(20), TwoDArray(3, 4)

Dim ZeroArray(0 To 5) ' .

Lower = LBound(MyArray) ' =1

Lower = LBound(TwoDArray, 2) ' 1.

Lower = LBound(ZeroArray) ' 0.

.

ReDim [Preserve] () [As type]

, . , (Preserve). Preserve .

ReDim X(10, 10, 10)

...

ReDim Preserve X(10, 10, 15)

: , , , Dim, , . , , , . . Erase, , .





:


: 2016-11-18; !; : 464 |


:

:

,
==> ...

1862 - | 1638 -


© 2015-2024 lektsii.org - -

: 0.01 .