Coverting single-value array into an ordinary variable

F

Fred Chow

Dear all,

I have a single-valued array X (i.e., its dimensions is 1-by-1) which holds
an integer. Is there an easy way of converting it back to an ordinary
integer variable? Thanks a lot.

Frederick Chow
Hong Kong
 
D

Dave Peterson

If you don't know how the array is dimensioned, you could do something like:

Dim myArr(7 To 7, 19 To 19) As Long
Dim myNumber As Long
myArr(7, 19) = 123 'assign it someway
myNumber = myArr(LBound(myArr, 1), LBound(myArr, 2))
MsgBox myNumber

If you knew the array dimensions:

Dim myArr(1 To 1, 1 To 1) As Long
Dim myNumber As Long
myArr(1,1) = 789 'assign it someway
myNumber = myArr(1, 1)
MsgBox myNumber
 
F

Fred Chow

Thanks a lot.

At least I know that there is no simple way of doing the job. Thanks.

Frederick Chow
Hong Kong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top