|
Prev: Hate Your Job?
Next: praktikum im ausland jobs und praktika im ausland jobs und praktika im ausland 2007 jobvermittlung ehrenamtlich arbeiten im ausland job vermittlung ausland jobboerse arbeit stellenangebote fuer ausland arbeiten im ausland spanien
From: argusy on 29 Jun 2008 09:56 George Hester wrote: > I would like to access just one dimension of a multi-column and rows array. > Something like if A(i,j) is an array with values for i and j how about > A(I,j) being just a one-dimensional array? I could be say the number of > elements i. Thanks. > > -- > > George Hester > _________________________________ > > I think you could do that in dBASE II, but not in VB (Define a two dim array, and then pick an array item with a single number. Gad!! That's a looong time ago!!)
From: dpb on 29 Jun 2008 10:31 George Hester wrote: > I would like to access just one dimension of a multi-column and rows array. > Something like if A(i,j) is an array with values for i and j how about > A(I,j) being just a one-dimensional array? I could be say the number of > elements i. Thanks. As others have noted, a sad lack in VB is the implementation of array slices and other array operations as part of the syntax... :( --
From: Bob O`Bob on 29 Jun 2008 14:01 Jim Mack wrote: > George Hester wrote: >> I would like to access just one dimension of a multi-column and >> rows array. Something like if A(i,j) is an array with values for i >> and j how about A(I,j) being just a one-dimensional array? I could >> be say the number of elements i. Thanks. > > VB doesn't natively allow that, but it's possible to fool VB into > thinking it does, depending on how the array is ordered. But it's a > hack, and has to be approached carefully. > > Basically, the idea is to create a blank single-dim array, and > manipulate its SafeArray structure to have the correct bounds, and a > pointer to the data of interest. > > It's not for the inexperienced or the careless, though. You can get > things bollixed up pretty well if you miss a step, or do something you > shouldn't. A somewhat safer alternative (but using more resources) is LSet. When the definitions of the members of a UDT are arranged appropriately, one can sometimes use LSet to move a block of data, intact, to an instance of a different type, which then gives different access to the same byte data. Option Explicit Public Type A twoD(0 To 9, 0 To 9) As Byte End Type Public Type C x(0 To 9) As Byte End Type Public Type B oneD(0 To 9) As C End Type Dim FirstOne As A Dim SecondOne As B Public Sub main() Dim i As Long, j As Long 'build some test data For i = 0 To 9 For j = 0 To 9 FirstOne.twoD(i, j) = Val(CStr(i) & CStr(j)) Next Next '"translate" LSet SecondOne = FirstOne 'read one For i = 0 To 9 Debug.Print SecondOne.oneD(5).x(i) Next End Sub Bob --
From: dpb on 30 Jun 2008 10:28 George Hester wrote: > I would like to access just one dimension of a multi-column and rows array. > Something like if A(i,j) is an array with values for i and j how about > A(I,j) being just a one-dimensional array? I could be say the number of > elements i. Thanks. .... Depending on what you're doing, rather than the use of the various other techniques the thread goes on to discuss, my favorite way is to write code that needs such array manipulation as a Fortran DLL. Fortran is very similar in overall syntax to BASIC, uses column-major array storage as does BASIC and w/ F95 and higher has the array syntax you're asking for. --
From: dpb on 30 Jun 2008 17:14
George Hester wrote: > Yes. I used to program in FORTRAN on a VAX maybe that's why I think this > should be available. I just have to whip out my Power FORTRAN on one of my > harddrives. It is installed there in Windows 2000 Prof. Do you have a site > that shows how to begin to make a Windows dll with FORTRAN? I also have the > IMSL F90 Library. > I'd suggest a newer Fortran compiler than MS PowerStation, though--it's known to be quite buggy and is getting quite long in the tooth now (not to mention it has virtually no support even on newsgroups that I'm aware of). Intel has a freely downloadable version I believe as well as there are gfortran and g95. I'm still using the CVF compiler which is also no longer supported (having been supplanted by the Intel one), but whichever compiler has support for DLLs. I would presume although I never used it to any extent owing to the problems in it that if you're adamant about PowerStation it will have some sample code with it as well. -- |