Re: Conversion Problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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 multidementional 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:9F09107A-9FEE-42DC-B775-A2EDB7FDB744@xxxxxxxxxxxxxxxx
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 representation (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@xxxxxxxxxxx> a écrit dans le message de groupe de discussion : uF9Fmes4IHA.996@xxxxxxxxxxxxxxxxxxxxxxx
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 dimentional 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@xxxxxxxxxxx> wrote in message news:%23EbLzPs4IHA.1892@xxxxxxxxxxxxxxxxxxxxxxx
Ok i've got the Runtime.InteropServices.... 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@xxxxxxxxxxx> wrote in message news:e%23pXH0r4IHA.3804@xxxxxxxxxxxxxxxxxxxxxxx
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 differences 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 something that works.

i tried Runtime.InteropServices.Marshal.SizeOf(GetType(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 statement 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:5117F78C-EEF3-4D66-888B-BCED135B7145@xxxxxxxxxxxxxxxx
An array is basically a pointer so the Len is not correct.

A trick could be to use <VBFixedArray(10 * 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 diagnose possible read/write problems more easily...

--
Patrice

"John" <no-email-supplied@xxxxxxxxxxx> a écrit dans le message de groupe de discussion : uh$p3Bo4IHA.4448@xxxxxxxxxxxxxxxxxxxxxxx
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(10,10,2) as Integer
Array2(20,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 <vbfixedarray> with more than 2 dementions so i cannot declare it correctly in the structure declaration.

What i have done is:

Structure 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 structures with openfile and random access? Why does vbfixedarray only allow 2 dementions?????

Cheers
John







.



Relevant Pages

  • Re: Conversion Problem
    ... OK forget it - there is a more serious problem with this, it seems that vb8 does not support arrays declared like arr1because when you try to do the Fileput it just gives an error saying only 2 dimentional arrays are supported - what a load of tat!!! ... dim arr1 ... vb8 won't let me use with more than 2 dementions so i cannot declare it correctly in the structure declaration. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: A Question on Arrays.
    ... cells) - Arrays where revamped in .NET so that dim stras string ... the VB.Net behavior is the same as VB6. ... indicating the number of members, but they changed it back to the VB6 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Conversion Problem
    ... VB6 side Ive got a xinteger array... ... the _x array is a single dimension array whose size is the same as the 3D array VB6 side. ... that vb8 does not support arrays declared like arr1because when you try to do the Fileput it just gives an error saying only 2 dimentional arrays are supported - what a load of tat!!! ... dim arr1 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Conversion Problem
    ... VB6 side Ive got a xinteger array... ... the _x array is a single dimension array whose size is the same as the 3D array VB6 side. ... vb8 does not support arrays declared like arr1because when you try to do the Fileput it just gives an error saying only 2 dimentional arrays are supported - what a load of tat!!! ... dim arr1 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Conversion Problem
    ... for the array or count is greater than the number of elements from index to the end of the source collection. ... VB6 side Ive got a xinteger array... ... that vb8 does not support arrays declared like arr1because when you try to do the Fileput it just gives an error saying only 2 dimentional arrays are supported - what a load of tat!!! ... dim arr1 ...
    (microsoft.public.dotnet.languages.vb)