Conversion Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Conversion Problem

    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 <vbfixedarraywi th 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

  • Nathan Sokalski

    #2
    Re: Conversion Problem

    It sounds like you are still adjusting to VB.NET. Have you looked at the
    documentation for the Len method? What you want to use is the GetLength (or
    the GetLongLength) method of the Array class. For example:

    x.GetLength(0)
    x.GetLength(1)
    x.GetLength(2)

    would return the values:

    10
    10
    2

    Hopefully this helps.
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。


    "John" <no-email-supplied@nothin g.comwrote in message
    news:uh$p3Bo4IH A.4448@TK2MSFTN GP05.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(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 <vbfixedarraywi th 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

    Comment

    • John

      #3
      Re: Conversion Problem

      i am totally confused by this reply, in your example it looks like the total
      length is 22? but an array of (10,10,2) would be 400 or more depending on
      the type of data. then there is all the other elements of the structure as
      well

      how exactly does your reply work when evaluating the record length to put in
      the FileOpen statement?

      sorry if i seem a bit dim :-) but i really don't understand your reply at
      all


      "Nathan Sokalski" <njsokalski@hot mail.comwrote in message
      news:%23sh5LNq4 IHA.2060@TK2MSF TNGP02.phx.gbl. ..
      It sounds like you are still adjusting to VB.NET. Have you looked at the
      documentation for the Len method? What you want to use is the GetLength
      (or the GetLongLength) method of the Array class. For example:
      >
      x.GetLength(0)
      x.GetLength(1)
      x.GetLength(2)
      >
      would return the values:
      >
      10
      10
      2
      >
      Hopefully this helps.
      --
      Nathan Sokalski
      njsokalski@hotm ail.com
      有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。

      >
      "John" <no-email-supplied@nothin g.comwrote in message
      news:uh$p3Bo4IH A.4448@TK2MSFTN GP05.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(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 <vbfixedarraywi th 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
      >
      >

      Comment

      • Patrice

        #4
        Re: Conversion Problem

        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.Intero pServices.Marhs l.SizeOf(GetTyp e(Short))*x.Len gth)

        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@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(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 <vbfixedarraywi th 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

        Comment

        • John

          #5
          Re: Conversion Problem

          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.Interop Services.Marsha l.SizeOf(GetTyp e(Short))*x.Len gth 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@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.Intero pServices.Marhs l.SizeOf(GetTyp e(Short))*x.Len gth)
          >
          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@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(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 <vbfixedarraywi th 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
          >
          >

          Comment

          • John

            #6
            Re: Conversion Problem

            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%23pXH0r4 IHA.3804@TK2MSF TNGP03.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 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.Interop Services.Marsha l.SizeOf(GetTyp e(Short))*x.Len gth
            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@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.Inter opServices.Marh sl.SizeOf(GetTy pe(Short))*x.Le ngth)
            >>
            >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@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(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 <vbfixedarraywi th 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
            >>
            >>
            >

            Comment

            • John

              #7
              Re: Conversion Problem

              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@nothin g.comwrote in message
              news:%23EbLzPs4 IHA.1892@TK2MSF TNGP06.phx.gbl. ..
              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%23pXH0r4 IHA.3804@TK2MSF TNGP03.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 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.Interop Services.Marsha l.SizeOf(GetTyp e(Short))*x.Len gth
              >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:5117F78 C-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.Inte ropServices.Mar hsl.SizeOf(GetT ype(Short))*x.L ength)
              >>>
              >>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@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(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 <vbfixedarraywi th 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
              >>>
              >>>
              >>
              >

              Comment

              • Ken Halter

                #8
                Re: Conversion Problem

                "John" <no-email-supplied@nothin g.comwrote in message
                news:e%23pXH0r4 IHA.3804@TK2MSF TNGP03.phx.gbl. ..
                >
                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
                It's not you... the dotNet "VB Team" hasn't a clue what VB is. They're all C
                programmers and re-wrote VB basically from the ground up, when the actual VB
                team bailed out. I'd almost bet the current VB team has never written an app
                in VB6, other than quick hacks to try something out.
                just to get the same thing as dim arr1(100,100,2)
                .....and, don't forget... those dimensions are 0 based, so that's 101 * 101 *
                3 elements... but that's all I have <gI use VB6 100% of the time at work
                and home, so I actually get stuff done..

                Just passin' thru


                Comment

                • Tom Shelton

                  #9
                  Re: Conversion Problem

                  On 2008-07-10, John <no-email-supplied@nothin g.comwrote:
                  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 <vbfixedarraywi th 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
                  >
                  You can alawys use COM interop and put your file access in a VB6 dll :) There
                  are a lot of differences between VB6's array implementation (SafeArray) and
                  ..NET's implementation - and so, there are probably going to be some differences
                  that might be hard to account for when reading binary files created in VB6...

                  --
                  Tom Shelton

                  Comment

                  • John

                    #10
                    Re: Conversion Problem

                    glad to know its not just me, i would not even have considered using vb8 but
                    i do like the new updated appearance and i was worried that eventually vb6
                    would not work with microsofts operating system updates.

                    practically everything i try and do that took a few seconds in vb6 takes
                    hours in this to sort out and then like this example i have spent nearly the
                    whole day trying to achieve something that cannot be done simply (the best
                    solution being create a vb6 dll to handle it (says it all really doesn't
                    it). I have many more examples, no contol arrays so you have to build them
                    at run time and spend hours trying to get the layout correct, - printing -
                    you cannot easily specify a new page without going into a recursive print
                    handler which takes more time trying to handle your printing, etc etc all
                    simple stuff but a nightmare in this product.



                    "Ken Halter" <Ken_Halter@Use _Sparingly_Hotm ail.comwrote in message
                    news:uyZ6I4s4IH A.4492@TK2MSFTN GP04.phx.gbl...
                    "John" <no-email-supplied@nothin g.comwrote in message
                    news:e%23pXH0r4 IHA.3804@TK2MSF TNGP03.phx.gbl. ..
                    >>
                    >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
                    >
                    It's not you... the dotNet "VB Team" hasn't a clue what VB is. They're all
                    C programmers and re-wrote VB basically from the ground up, when the
                    actual VB team bailed out. I'd almost bet the current VB team has never
                    written an app in VB6, other than quick hacks to try something out.
                    >
                    >just to get the same thing as dim arr1(100,100,2)
                    >
                    ....and, don't forget... those dimensions are 0 based, so that's 101 * 101
                    * 3 elements... but that's all I have <gI use VB6 100% of the time at
                    work and home, so I actually get stuff done..
                    >
                    Just passin' thru
                    >

                    Comment

                    • Tom Shelton

                      #11
                      Re: Conversion Problem

                      On 2008-07-10, John <no-email-supplied@nothin g.comwrote:
                      glad to know its not just me, i would not even have considered using vb8 but
                      i do like the new updated appearance and i was worried that eventually vb6
                      would not work with microsofts operating system updates.
                      >
                      practically everything i try and do that took a few seconds in vb6 takes
                      hours in this to sort out and then like this example i have spent nearly the
                      whole day trying to achieve something that cannot be done simply (the best
                      solution being create a vb6 dll to handle it (says it all really doesn't
                      it). I have many more examples, no contol arrays so you have to build them
                      at run time and spend hours trying to get the layout correct, - printing -
                      you cannot easily specify a new page without going into a recursive print
                      handler which takes more time trying to handle your printing, etc etc all
                      simple stuff but a nightmare in this product.
                      >
                      LOL... The problem is John, that you are not familiar enough with the
                      framework and .NET. Once you become so, on the whole things are MUCH easier
                      then VB6. I know, I spent years doing VB work. I'm not claiming every thing
                      is easier, just most.

                      Your example of control arrays is pretty funny - I
                      don't even miss them. First off, the main reason in VB.CLASSIC for control
                      arrays was 1) common event handling and 2) avoiding the 256 unique control
                      names per form limit (or was it 255?). 2 doesn't apply in VB.NET and 1 is
                      handled by the fact that VB.NET events allow an event to be assigned to
                      multiple controls (heck, they don't even have to be the same type)...

                      ' you can do this in the ide - just select all of the controls you want, go
                      ' to the event tab in the properties window and add the handler - the ide will
                      ' automatically add the handles list :)
                      Private Sub Button_Click (ByVal sender As Object, ByVal e As EventArgs) _
                      Handles Button1.Click, Button2.Click, Button3.Click

                      Dim clickedButton As Button = DirectCast (sender, Button)
                      ' do button stuff
                      End Sub

                      There are times that using index's to access a control are helpful... And
                      even that is a fairly simple task.

                      Public Class MyForm
                      Inherits System.Windows. Forms.Form

                      Private buttons() As Button = new Button() {Button1, Button2, Button3}

                      ...

                      Private Sub DoCoolStuff(ByV al btnIndex As Integer)
                      Dim theButton As Button = buttons(btnInde x)
                      ' do cool stuff with the button
                      End Sub
                      End Class

                      Or you can index them from the containser controls collection at runtime by
                      the name:

                      Dim theButton As Button = DirectCast(Me.C ontrols("theBut ton"), Button)

                      There is no need to dynamically generate controls... You just have to
                      understand the differences and the capabilites of VB.NET and then you don't
                      have these types of issues (well, at least not as often).

                      As for your file issue, I only was half joking about your file access - the
                      fact is that .NET is a different target platform then VB6. VB6 targeted COM
                      and so it has a lot of COM'isms - such as SafeArrays - and so in some ways is
                      not compatable. Personally, if I were you I would create a VB6 component that
                      would be able to convert the files into a more .NET friendly format and then
                      access them using the System.IO namespace classes. The FileXXX VB.NET native
                      functions are crap...

                      --
                      Tom Shelton

                      Comment

                      • John

                        #12
                        Re: Conversion Problem

                        You are quite correct in saying i am not familiar enough with the framework
                        and .NET. My problem seems to be i'm trying to do the same things in vb.net
                        as i did in vb6 rather than taking the new approach to it. Frustrating never
                        the less.

                        It would certainly assist if the help provided more practical examples. I
                        suppose i should buy a book!

                        "Tom Shelton" <tom_shelton@co mcastXXXXXXX.ne twrote in message
                        news:3rmdnZmPI7 VnFOvVnZ2dnUVZ_ qXinZ2d@comcast .com...
                        On 2008-07-10, John <no-email-supplied@nothin g.comwrote:
                        >glad to know its not just me, i would not even have considered using vb8
                        >but
                        >i do like the new updated appearance and i was worried that eventually
                        >vb6
                        >would not work with microsofts operating system updates.
                        >>
                        >practically everything i try and do that took a few seconds in vb6 takes
                        >hours in this to sort out and then like this example i have spent nearly
                        >the
                        >whole day trying to achieve something that cannot be done simply (the
                        >best
                        >solution being create a vb6 dll to handle it (says it all really doesn't
                        >it). I have many more examples, no contol arrays so you have to build
                        >them
                        >at run time and spend hours trying to get the layout correct, -
                        >printing -
                        >you cannot easily specify a new page without going into a recursive print
                        >handler which takes more time trying to handle your printing, etc etc all
                        >simple stuff but a nightmare in this product.
                        >>
                        >
                        LOL... The problem is John, that you are not familiar enough with the
                        framework and .NET. Once you become so, on the whole things are MUCH
                        easier
                        then VB6. I know, I spent years doing VB work. I'm not claiming every
                        thing
                        is easier, just most.
                        >
                        Your example of control arrays is pretty funny - I
                        don't even miss them. First off, the main reason in VB.CLASSIC for
                        control
                        arrays was 1) common event handling and 2) avoiding the 256 unique control
                        names per form limit (or was it 255?). 2 doesn't apply in VB.NET and 1 is
                        handled by the fact that VB.NET events allow an event to be assigned to
                        multiple controls (heck, they don't even have to be the same type)...
                        >
                        ' you can do this in the ide - just select all of the controls you want,
                        go
                        ' to the event tab in the properties window and add the handler - the ide
                        will
                        ' automatically add the handles list :)
                        Private Sub Button_Click (ByVal sender As Object, ByVal e As EventArgs) _
                        Handles Button1.Click, Button2.Click, Button3.Click
                        >
                        Dim clickedButton As Button = DirectCast (sender, Button)
                        ' do button stuff
                        End Sub
                        >
                        There are times that using index's to access a control are helpful... And
                        even that is a fairly simple task.
                        >
                        Public Class MyForm
                        Inherits System.Windows. Forms.Form
                        >
                        Private buttons() As Button = new Button() {Button1, Button2, Button3}
                        >
                        ...
                        >
                        Private Sub DoCoolStuff(ByV al btnIndex As Integer)
                        Dim theButton As Button = buttons(btnInde x)
                        ' do cool stuff with the button
                        End Sub
                        End Class
                        >
                        Or you can index them from the containser controls collection at runtime
                        by
                        the name:
                        >
                        Dim theButton As Button = DirectCast(Me.C ontrols("theBut ton"), Button)
                        >
                        There is no need to dynamically generate controls... You just have to
                        understand the differences and the capabilites of VB.NET and then you
                        don't
                        have these types of issues (well, at least not as often).
                        >
                        As for your file issue, I only was half joking about your file access -
                        the
                        fact is that .NET is a different target platform then VB6. VB6 targeted
                        COM
                        and so it has a lot of COM'isms - such as SafeArrays - and so in some ways
                        is
                        not compatable. Personally, if I were you I would create a VB6 component
                        that
                        would be able to convert the files into a more .NET friendly format and
                        then
                        access them using the System.IO namespace classes. The FileXXX VB.NET
                        native
                        functions are crap...
                        >
                        --
                        Tom Shelton

                        Comment

                        • Patrice

                          #13
                          Re: Conversion Problem

                          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@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 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@nothin g.comwrote in message
                          news:%23EbLzPs4 IHA.1892@TK2MSF TNGP06.phx.gbl. ..
                          >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%23pXH0r 4IHA.3804@TK2MS FTNGP03.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 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.Interop Services.Marsha l.SizeOf(GetTyp e(Short))*x.Len gth
                          >>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:5117F7 8C-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.Int eropServices.Ma rhsl.SizeOf(Get Type(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@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(10,1 0,2) as Integer
                          >>>>Array2(20,2 0,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:
                          >>>>>
                          >>>>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
                          >>>>structure s with openfile and random access? Why does vbfixedarray only
                          >>>>allow 2 dementions?????
                          >>>>>
                          >>>>Cheers
                          >>>>John
                          >>>>
                          >>>>
                          >>>
                          >>
                          >

                          Comment

                          • John

                            #14
                            Re: Conversion Problem

                            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:9F09107A-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
                            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@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 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@nothin g.comwrote in message
                            >news:%23EbLzPs 4IHA.1892@TK2MS FTNGP06.phx.gbl ...
                            >>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%23pXH0 r4IHA.3804@TK2M SFTNGP03.phx.gb l...
                            >>>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.Interop Services.Marsha l.SizeOf(GetTyp e(Short))*x.Len gth
                            >>>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:5117F78 C-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.In teropServices.M arhsl.SizeOf(Ge tType(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@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(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 <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

                            • Patrice

                              #15
                              Re: Conversion Problem

                              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...
                              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:9F09107A-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
                              >representati on (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
                              >>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@nothin g.comwrote in message
                              >>news:%23EbLzP s4IHA.1892@TK2M SFTNGP06.phx.gb l...
                              >>>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%23pXH 0r4IHA.3804@TK2 MSFTNGP03.phx.g bl...
                              >>>>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
                              >>>>differenc es 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.Int eropServices.Ma rshal.SizeOf(Ge tType(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:5117F7 8C-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.I nteropServices. Marhsl.SizeOf(G etType(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@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(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 <vbfixedarraywi th more than 2 dementions so i
                              >>>>>>cannot declare it correctly in the structure declaration.
                              >>>>>>>
                              >>>>>>What i have done is:
                              >>>>>>>
                              >>>>>>Structu re 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
                              >>>>>>structure s with openfile and random access? Why does vbfixedarray
                              >>>>>>only allow 2 dementions?????
                              >>>>>>>
                              >>>>>>Cheers
                              >>>>>>John
                              >>>>>>
                              >>>>>>
                              >>>>>
                              >>>>
                              >>>
                              >>
                              >

                              Comment

                              Working...