Sihua,
Judging from your example, I take it that you have a background in
C/C++, which has an elegant way of initializing arrays in
code. Standard VBA might include a similar (though more clumsy)
mechanism, but that has been left out of E-Basic. So as the previous
respondant says, you just need to assign each array element in turn
with its own assignment statement. Of course you also need to first
declare your arrays, thus,
Dim a(1 to 36) as Integer ' use explicit array bounds to
reduce confusion
Dim b(1 to 12) as Integer
a(1) = 2
a(2) = 3
...
b(1) = 12
b(2) = 7
...
and if you like you can collapse that using the colon statement separator,
Dim a(1 to 36) as Integer ' use explicit array bounds to
reduce confusion
Dim b(1 to 12) as Integer
a(1) = 2: a(2) = 3: ...
b(1) = 12: b(2) = 7: ...
but it is still clumsy and ugly no matter how you do it. This is
really elementary VBA programming, so for more info I recommend an
intro VBA programming book such as "VBA for Dummies".
If it were me, I might instead use a List for initializing and
randomizing, but that is more than I can go into here.
-----
David McFarlane
E-Prime training
online:
http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (
https://twitter.com/EPrimeMaster )
/----
Stock reminder: 1) I do not work for PST. 2) PST's trained staff
take any and all questions at
https://support.pstnet.com , and they
strive to respond to all requests in 24-48 hours, so make full use of
it. 3) In addition, PST offers several instructional videos on their
YouTube channel (
http://www.youtube.com/user/PSTNET ). 4) If you do
get an answer from PST staff, please extend the courtesy of posting
their reply back here for the sake of others.
\----
At 11/3/2013 10:23 PM Sunday, gorgeous yayuan geng wrote:
>Dear,
>
>you should defiine the array one by one like this, a(1)=2 a(2)=3
>and you can random the array use the arrayrandomize method. then you
>can get a random number use random method ,then
>randomizearray a
>t=random(1,ubound(a))
>a(t) is what you want.
>Hope this help.
>
>
>2013/11/4 sihua xu <<mailto:
xusi...@gmail.com>
xusi...@gmail.com>