Re: Conversion Problem
Are you sure i + j * 2 + k * 2 * 3 gives the required index for the new
array only this doesn't seem to work
I can now get the records ok and get back all the other information but when
i use the i,j,k to get the value from xcoords(100, 10, 2) or
ycoords(100,10, 2) I seem to get zero returned when it is not zero.
for example if i need to access xcoords(1,1,1) this translates to accessing
xcoords(9) in the new array is that correct? Or should there be some
brackets in the above evaluation.
"Patrice" <http://www.chez.com/scribe/wrote in message
news:BAF19267-E4A6-4845-84BC-63B8AB985100@mi crosoft.com...
Are you sure i + j * 2 + k * 2 * 3 gives the required index for the new
array only this doesn't seem to work
I can now get the records ok and get back all the other information but when
i use the i,j,k to get the value from xcoords(100, 10, 2) or
ycoords(100,10, 2) I seem to get zero returned when it is not zero.
for example if i need to access xcoords(1,1,1) this translates to accessing
xcoords(9) in the new array is that correct? Or should there be some
brackets in the above evaluation.
"Patrice" <http://www.chez.com/scribe/wrote in message
news:BAF19267-E4A6-4845-84BC-63B8AB985100@mi crosoft.com...
So for the array issue I tried the following :
>
VB6 side Ive got a x(1,2,3) integer array...
>
VB.NET side I've got the following structure :
>
<VBFixedArray(2 3)Public _x() As Short
>
Public Property x(ByVal i As Integer, ByVal j As Integer, ByVal k As
Integer) As Short
Get
Return _x(i + j * 2 + k * 2 * 3)
End Get
Set(ByVal value As Short)
' TODO
End Set
End Property
>
That is :
>
- the _x array is a single dimension array whose size is the same as the
3D array VB6 side. It allows to read the array using FileGet
>
- I expose this array as a 3D array using a property so that x looks like
a 3D array... (each cell is at a position so that each index uses the
number of elements for all the previous indices as an offset)
>
It should be similar enough to VB6 to be usable while watijgn perhaps to
switch to something better if another idea or a later update gives better
support...
>
--
Patrice
>
"John" <no-email-supplied@nothin g.coma écrit dans le message de groupe
de discussion : #6CgA4z4IHA.439 2@TK2MSFTNGP03. phx.gbl...
>
>
VB6 side Ive got a x(1,2,3) integer array...
>
VB.NET side I've got the following structure :
>
<VBFixedArray(2 3)Public _x() As Short
>
Public Property x(ByVal i As Integer, ByVal j As Integer, ByVal k As
Integer) As Short
Get
Return _x(i + j * 2 + k * 2 * 3)
End Get
Set(ByVal value As Short)
' TODO
End Set
End Property
>
That is :
>
- the _x array is a single dimension array whose size is the same as the
3D array VB6 side. It allows to read the array using FileGet
>
- I expose this array as a 3D array using a property so that x looks like
a 3D array... (each cell is at a position so that each index uses the
number of elements for all the previous indices as an offset)
>
It should be similar enough to VB6 to be usable while watijgn perhaps to
switch to something better if another idea or a later update gives better
support...
>
--
Patrice
>
"John" <no-email-supplied@nothin g.coma écrit dans le message de groupe
de discussion : #6CgA4z4IHA.439 2@TK2MSFTNGP03. phx.gbl...
>Hi Patrice
>>
>My overall intent is to convert an existing VB6 application into vb.net
>so I can still use multiple records I created in the new application. I
>have managed to handle all the other type conversions so vb net handles
>then using the fileopen, fileget, fileput but the following record as
>stopped the conversion in its tracks because of the multidementiona l
>array aspect.
>>
>The vb6 type structure is as follows:
>>
>Type satlocation
>>
> origin As Integer
>>
> locationfixed As Boolean
>>
> timefixed As Boolean
>>
> numberofsets As Integer
>>
> xcoords(100, 10, 2) As Single
>>
> ycoords(100, 10, 2) As Single
>>
> stamp As Date
>>
>End Type
>>
>What I need to do is to be able to read and write to randomly to existing
>data in the above record set that was created under vb6 - as you can see
>there are literally thousands of cords that I certainly do not want to
>input again, so basically I need to use the this same record set.
>>
>>
>>
>"Patrice" <http://www.chez.com/scribe/wrote in message
>news:9F09107 A-9FEE-42DC-B775-A2EDB7FDB744@mi crosoft.com...
>>
>>
>My overall intent is to convert an existing VB6 application into vb.net
>so I can still use multiple records I created in the new application. I
>have managed to handle all the other type conversions so vb net handles
>then using the fileopen, fileget, fileput but the following record as
>stopped the conversion in its tracks because of the multidementiona l
>array aspect.
>>
>The vb6 type structure is as follows:
>>
>Type satlocation
>>
> origin As Integer
>>
> locationfixed As Boolean
>>
> timefixed As Boolean
>>
> numberofsets As Integer
>>
> xcoords(100, 10, 2) As Single
>>
> ycoords(100, 10, 2) As Single
>>
> stamp As Date
>>
>End Type
>>
>What I need to do is to be able to read and write to randomly to existing
>data in the above record set that was created under vb6 - as you can see
>there are literally thousands of cords that I certainly do not want to
>input again, so basically I need to use the this same record set.
>>
>>
>>
>"Patrice" <http://www.chez.com/scribe/wrote in message
>news:9F09107 A-9FEE-42DC-B775-A2EDB7FDB744@mi crosoft.com...
>>What is the overall intent ? It's true that VB.NET is different. For
>>example the way to persists data is totally different so if you need to
>>read legacy data, it might be usefull to consider the other options that
>>.NET could bring to the table ("serialization " i..e the ability to
>>persist data structure to disk or using datasets that are a in memory db
>>representatio n (suitable only for small amouts of data) or a real db.
>>>
>>Let me know if you are still heading to VB.NET I'll try to give this a
>>closer look with a working sample...
>>>
>>>
>>--
>>Patrice
>>>
>>>
>>"John" <no-email-supplied@nothin g.coma écrit dans le message de groupe
>>de discussion : uF9Fmes4IHA.996 @TK2MSFTNGP04.p hx.gbl...
>>>OK forget it - there is a more serious problem with this, it seems that
>>>vb8 does not support arrays declared like arr1(10,10,10) because when
>>>you try to do the Fileput it just gives an error saying only 2
>>>dimentiona l arrays are supported - what a load of tat!!!
>>>>
>>>i think i'll go back to vb6 that was a true RAD piece of kit, my only
>>>other option it seems is to scrap all my hundreds of records and then
>>>design the structure in vb8 so that it is something like
>>>>
>>>dim arr1(100,2)
>>>dim arr2(100,2)
>>>:
>>>:
>>>dim arr100(100,2)
>>>>
>>>>
>>>just to get the same thing as dim arr1(100,100,2)
>>>>
>>>"John" <no-email-supplied@nothin g.comwrote in message
>>>news:%23EbLz Ps4IHA.1892@TK2 MSFTNGP06.phx.g bl...
>>>>Ok i've got the Runtime.Interop Services.... bit to work
>>>>>
>>>>I've done it on all the elements of the structure and added them
>>>>together but i'm 4 bytes out?
>>>>>
>>>>I suppose i could just hard code the record length - but it seems a
>>>>very poor way of doing things.
>>>>>
>>>>>
>>>>"John" <no-email-supplied@nothin g.comwrote in message
>>>>news:e%23pX H0r4IHA.3804@TK 2MSFTNGP03.phx. gbl...
>>>>>thanks Patrice for that - i considered doing a fudge but the values
>>>>>are out so there seems to be an overhead in the array structure
>>>>>difference s in the vb6 and vb8 - the 2 values do not come out the
>>>>>same anyway- they are a few hundred bytes different so the chances of
>>>>>reading and writing correctly into the old records is zero, and i
>>>>>don't fancy spending the rest of my life just trying to fudge
>>>>>somethin g that works.
>>>>>>
>>>>>i tried
>>>>>Runtime.In teropServices.M arshal.SizeOf(G etType(Short))* x.Length but
>>>>>it just gives me an error saying length is not a member of x so i
>>>>>don't know whether this would work or not!!
>>>>>>
>>>>>god i really hate this vb.net stuff - why is everything such a
>>>>>pain? - nothing seems logical (for example, why have a vbfixedarray
>>>>>statemen t that is limited to 2 dimentions?) and why they call it vb
>>>>>god knows, i've used vb since the 70's without any problem everything
>>>>>i try to do in this turns out to be a nightmare - perhaps i'm just
>>>>>too old and fixed in my ways
>>>>>>
>>>>>>
>>>>>"Patrice " <http://www.chez.com/scribe/wrote in message
>>>>>news:5117F 78C-EEF3-4D66-888B-BCED135B7145@mi crosoft.com...
>>>>>>An array is basically a pointer so the Len is not correct.
>>>>>>>
>>>>>>A trick could be to use <VBFixedArray(1 0 * 10 * 4)x() As Short to
>>>>>>read your data and possibly to copy in the final array (it might be
>>>>>>needed anyway as I'm not sure if .NET arrays and VB arrays are
>>>>>>storing data using the same ordering).
>>>>>>>
>>>>>>Another option would be to compute the record length
>>>>>>(Runtime. InteropServices .Marhsl.SizeOf( GetType(Short)) *x.Length)
>>>>>>>
>>>>>>Another option could be to read each member, you can add a method to
>>>>>>your structure to do add (youll need just the overall size, is this
>>>>>>a constant in your case ?) and AFAIK datta are read based on the
>>>>>>length of the receiving object (depends also how is was done in VB I
>>>>>>suppose ).
>>>>>>>
>>>>>>Your best bet would be likely to create a small test case using VB
>>>>>>and reading use VB.NET wiht easy checkable values to test and
>>>>>>diagnos e possible read/write problems more easily...
>>>>>>>
>>>>>>--
>>>>>>Patrice
>>>>>>>
>>>>>>"John" <no-email-supplied@nothin g.coma écrit dans le message de
>>>>>>groupe de discussion : uh$p3Bo4IHA.444 8@TK2MSFTNGP05. phx.gbl...
>>>>>>>Hi
>>>>>>>>
>>>>>>>This .net is driving me crazy!!
>>>>>>>>
>>>>>>>In VB6 I had a type which contained a couple of multi-dimentional
>>>>>>>arrays which i used to create and read records:
>>>>>>>>
>>>>>>>Type AAA
>>>>>>>:
>>>>>>>Array1(1 0,10,2) as Integer
>>>>>>>Array2(2 0,20,4) as Integer
>>>>>>>:
>>>>>>>End Type
>>>>>>>>
>>>>>>>I'm trying to get vb8 set up so that i can use the same files and
>>>>>>>use the fileopen method to randomly access the file data etc
>>>>>>>>
>>>>>>>vb8 won't let me use <vbfixedarraywi th more than 2 dementions so
>>>>>>>i cannot declare it correctly in the structure declaration.
>>>>>>>>
>>>>>>>What i have done is:
>>>>>>>>
>>>>>>>Structur e z
>>>>>>>:
>>>>>>>dim Array1(,,) as short
>>>>>>>dim Array2(,,) as short
>>>>>>>:
>>>>>>>End Structure
>>>>>>>>
>>>>>>>>
>>>>>>>Dim x as z
>>>>>>>I have then tried to Redim in an initialation so:
>>>>>>>>
>>>>>>>>
>>>>>>>redim x.array1(10,10, 2)
>>>>>>>redim x.array2(20,20, 4)
>>>>>>>>
>>>>>>>But when i go to get the record length Len(x) it is totally wrong
>>>>>>>>
>>>>>>>Is there any way out of this mess so i can use my original record
>>>>>>>structur es with openfile and random access? Why does vbfixedarray
>>>>>>>only allow 2 dementions?????
>>>>>>>>
>>>>>>>Cheers
>>>>>>>John
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>example the way to persists data is totally different so if you need to
>>read legacy data, it might be usefull to consider the other options that
>>.NET could bring to the table ("serialization " i..e the ability to
>>persist data structure to disk or using datasets that are a in memory db
>>representatio n (suitable only for small amouts of data) or a real db.
>>>
>>Let me know if you are still heading to VB.NET I'll try to give this a
>>closer look with a working sample...
>>>
>>>
>>--
>>Patrice
>>>
>>>
>>"John" <no-email-supplied@nothin g.coma écrit dans le message de groupe
>>de discussion : uF9Fmes4IHA.996 @TK2MSFTNGP04.p hx.gbl...
>>>OK forget it - there is a more serious problem with this, it seems that
>>>vb8 does not support arrays declared like arr1(10,10,10) because when
>>>you try to do the Fileput it just gives an error saying only 2
>>>dimentiona l arrays are supported - what a load of tat!!!
>>>>
>>>i think i'll go back to vb6 that was a true RAD piece of kit, my only
>>>other option it seems is to scrap all my hundreds of records and then
>>>design the structure in vb8 so that it is something like
>>>>
>>>dim arr1(100,2)
>>>dim arr2(100,2)
>>>:
>>>:
>>>dim arr100(100,2)
>>>>
>>>>
>>>just to get the same thing as dim arr1(100,100,2)
>>>>
>>>"John" <no-email-supplied@nothin g.comwrote in message
>>>news:%23EbLz Ps4IHA.1892@TK2 MSFTNGP06.phx.g bl...
>>>>Ok i've got the Runtime.Interop Services.... bit to work
>>>>>
>>>>I've done it on all the elements of the structure and added them
>>>>together but i'm 4 bytes out?
>>>>>
>>>>I suppose i could just hard code the record length - but it seems a
>>>>very poor way of doing things.
>>>>>
>>>>>
>>>>"John" <no-email-supplied@nothin g.comwrote in message
>>>>news:e%23pX H0r4IHA.3804@TK 2MSFTNGP03.phx. gbl...
>>>>>thanks Patrice for that - i considered doing a fudge but the values
>>>>>are out so there seems to be an overhead in the array structure
>>>>>difference s in the vb6 and vb8 - the 2 values do not come out the
>>>>>same anyway- they are a few hundred bytes different so the chances of
>>>>>reading and writing correctly into the old records is zero, and i
>>>>>don't fancy spending the rest of my life just trying to fudge
>>>>>somethin g that works.
>>>>>>
>>>>>i tried
>>>>>Runtime.In teropServices.M arshal.SizeOf(G etType(Short))* x.Length but
>>>>>it just gives me an error saying length is not a member of x so i
>>>>>don't know whether this would work or not!!
>>>>>>
>>>>>god i really hate this vb.net stuff - why is everything such a
>>>>>pain? - nothing seems logical (for example, why have a vbfixedarray
>>>>>statemen t that is limited to 2 dimentions?) and why they call it vb
>>>>>god knows, i've used vb since the 70's without any problem everything
>>>>>i try to do in this turns out to be a nightmare - perhaps i'm just
>>>>>too old and fixed in my ways
>>>>>>
>>>>>>
>>>>>"Patrice " <http://www.chez.com/scribe/wrote in message
>>>>>news:5117F 78C-EEF3-4D66-888B-BCED135B7145@mi crosoft.com...
>>>>>>An array is basically a pointer so the Len is not correct.
>>>>>>>
>>>>>>A trick could be to use <VBFixedArray(1 0 * 10 * 4)x() As Short to
>>>>>>read your data and possibly to copy in the final array (it might be
>>>>>>needed anyway as I'm not sure if .NET arrays and VB arrays are
>>>>>>storing data using the same ordering).
>>>>>>>
>>>>>>Another option would be to compute the record length
>>>>>>(Runtime. InteropServices .Marhsl.SizeOf( GetType(Short)) *x.Length)
>>>>>>>
>>>>>>Another option could be to read each member, you can add a method to
>>>>>>your structure to do add (youll need just the overall size, is this
>>>>>>a constant in your case ?) and AFAIK datta are read based on the
>>>>>>length of the receiving object (depends also how is was done in VB I
>>>>>>suppose ).
>>>>>>>
>>>>>>Your best bet would be likely to create a small test case using VB
>>>>>>and reading use VB.NET wiht easy checkable values to test and
>>>>>>diagnos e possible read/write problems more easily...
>>>>>>>
>>>>>>--
>>>>>>Patrice
>>>>>>>
>>>>>>"John" <no-email-supplied@nothin g.coma écrit dans le message de
>>>>>>groupe de discussion : uh$p3Bo4IHA.444 8@TK2MSFTNGP05. phx.gbl...
>>>>>>>Hi
>>>>>>>>
>>>>>>>This .net is driving me crazy!!
>>>>>>>>
>>>>>>>In VB6 I had a type which contained a couple of multi-dimentional
>>>>>>>arrays which i used to create and read records:
>>>>>>>>
>>>>>>>Type AAA
>>>>>>>:
>>>>>>>Array1(1 0,10,2) as Integer
>>>>>>>Array2(2 0,20,4) as Integer
>>>>>>>:
>>>>>>>End Type
>>>>>>>>
>>>>>>>I'm trying to get vb8 set up so that i can use the same files and
>>>>>>>use the fileopen method to randomly access the file data etc
>>>>>>>>
>>>>>>>vb8 won't let me use <vbfixedarraywi th more than 2 dementions so
>>>>>>>i cannot declare it correctly in the structure declaration.
>>>>>>>>
>>>>>>>What i have done is:
>>>>>>>>
>>>>>>>Structur e z
>>>>>>>:
>>>>>>>dim Array1(,,) as short
>>>>>>>dim Array2(,,) as short
>>>>>>>:
>>>>>>>End Structure
>>>>>>>>
>>>>>>>>
>>>>>>>Dim x as z
>>>>>>>I have then tried to Redim in an initialation so:
>>>>>>>>
>>>>>>>>
>>>>>>>redim x.array1(10,10, 2)
>>>>>>>redim x.array2(20,20, 4)
>>>>>>>>
>>>>>>>But when i go to get the record length Len(x) it is totally wrong
>>>>>>>>
>>>>>>>Is there any way out of this mess so i can use my original record
>>>>>>>structur es with openfile and random access? Why does vbfixedarray
>>>>>>>only allow 2 dementions?????
>>>>>>>>
>>>>>>>Cheers
>>>>>>>John
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
Comment