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
Jul 10 '08
43 2369
On 2008-07-10, John <no************ ***@nothing.com wrote:
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
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" <to*********@co mcastXXXXXXX.ne twrote in message
news:3r******** *************** *******@comcast .com...
On 2008-07-10, John <no************ ***@nothing.com wrote:
>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
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************ ***@nothing.com a écrit dans le message de groupe de
discussion : uF************* @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************ ***@nothing.com wrote in message
news:%2******** ********@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************ ***@nothing.com wrote in message news:e%******* *********@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:51****** *************** *************@m icrosoft.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************ ***@nothing.com a écrit dans le message de groupe de discussion : uh************* *@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
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:9F******** *************** ***********@mic rosoft.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************ ***@nothing.com a écrit dans le message de groupe
de discussion : uF************* @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************ ***@nothing.com wrote in message news:%2******* *********@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************ ***@nothing.com wrote in message news:e%****** **********@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:51***** *************** **************@ microsoft.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************ ***@nothing.com a écrit dans le message de groupe de discussion : uh************* *@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 > >
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************ ***@nothing.com a écrit dans le message de groupe de
discussion : #6************* *@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:9F******** *************** ***********@mic rosoft.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************ ***@nothing.com a écrit dans le message de groupe de discussion : uF************* @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************ ***@nothing.com wrote in message news:%2****** **********@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************ ***@nothing.com wrote in message news:e%***** ***********@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:51**** *************** *************** @microsoft.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************ ***@nothing.com a écrit dans le message de >groupe de discussion : uh************* *@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 >> >> >
I've already tried to do something similar, but for some bizzar reason the
record lenghts in the vb are different to the so called equivalent in the
net and without knowing the reason why the chances of getting the correct
data back (even if it doesn't give an error) are pretty remote
"Patrice" <http://www.chez.com/scribe/wrote in message
news:BA******** *************** ***********@mic rosoft.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************ ***@nothing.com a écrit dans le message de groupe
de discussion : #6************* *@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:9F******* *************** ************@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************ ***@nothing.com a écrit dans le message de groupe de discussion : uF************* @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************ ***@nothing.com wrote in message news:%2***** ***********@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************ ***@nothing.com wrote in message news:e%**** ************@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:51*** *************** *************** *@microsoft.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************ ***@nothing.com a écrit dans le message de >>groupe de discussion : uh************* *@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 >>> >>> >> >
Works here . Are they fixed array VB 6 side ? I've seen in the doc that a
prefix is written or not depending on the exact type of the variable. For
example if you write a single record using VB6 what is the exact size of
your file in bytes ? (mine is 48 that is 2 elements*3 elements *4 elements*2
bytes).
Byte alignement could also come in to play and it's also possible to control
this
( http://msdn.microsoft.com/en-us/libr...e(VS.80).aspx).
Also be aware of your "option base" (do I remember ?). Are VB6 array 1 based
or 0 based. They are always 0 based in VB.NET....
I'm quite confident it can be done, I'll try to give this a closer look
later with your structure layout...
--
Patrice
"John" <no************ ***@nothing.com a écrit dans le message de groupe de
discussion : OR************* *@TK2MSFTNGP03. phx.gbl...
I've already tried to do something similar, but for some bizzar reason the
record lenghts in the vb are different to the so called equivalent in the
net and without knowing the reason why the chances of getting the correct
data back (even if it doesn't give an error) are pretty remote
"Patrice" <http://www.chez.com/scribe/wrote in message
news:BA******** *************** ***********@mic rosoft.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************ ***@nothing.com a écrit dans le message de groupe de discussion : #6************* *@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:9F****** *************** *************@m icrosoft.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************ ***@nothing.com a écrit dans le message de groupe de discussion : uF************* @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 dimention al 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************ ***@nothing.com wrote in message news:%2**** ************@TK 2MSFTNGP06.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************ ***@nothing.com wrote in message >news:e%*** *************@T K2MSFTNGP03.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 >>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 >>somethi ng that works. >>> >>i tried >>Runtime.I nteropServices. 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 >>stateme nt 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 >>everythin g i try to do in this turns out to be a nightmare - perhaps >>i'm just too old and fixed in my ways >>> >>> >>"Patric e" <http://www.chez.com/scribe/wrote in message >>news:51** *************** *************** **@microsoft.co m... >>>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 >>>storin g data using the same ordering). >>>> >>>Anothe r option would be to compute the record length >>>(Runtime .InteropService s.Marhsl.SizeOf (GetType(Short) )*x.Length) >>>> >>>Anothe r 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 >>>diagno se possible read/write problems more easily... >>>> >>>-- >>>Patric e >>>> >>>"John" <no************ ***@nothing.com a écrit dans le message de >>>groupe de discussion : uh************* *@TK2MSFTNGP05. phx.gbl... >>>>Hi >>>>> >>>>This .net is driving me crazy!! >>>>> >>>>In VB6 I had a type which contained a couple of multi-dimentional >>>>array s 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 >>>>structu res with openfile and random access? Why does vbfixedarray >>>>only allow 2 dementions????? >>>>> >>>>Cheer s >>>>John >>>> >>>> >>> >> >
No it was my mistake, the values are the same I forgot to subtract 1.
However when i do a FileGet(fileno, gamecoords, 1) on this record it fails.
"Patrice" <http://www.chez.com/scribe/wrote in message
news:e0******** ******@TK2MSFTN GP06.phx.gbl...
Works here . Are they fixed array VB 6 side ? I've seen in the doc that a
prefix is written or not depending on the exact type of the variable. For
example if you write a single record using VB6 what is the exact size of
your file in bytes ? (mine is 48 that is 2 elements*3 elements *4
elements*2 bytes).
Byte alignement could also come in to play and it's also possible to
control this
(http://msdn.microsoft.com/en-us/libr...e(VS.80).aspx).
Also be aware of your "option base" (do I remember ?). Are VB6 array 1
based or 0 based. They are always 0 based in VB.NET....
I'm quite confident it can be done, I'll try to give this a closer look
later with your structure layout...
--
Patrice
"John" <no************ ***@nothing.com a écrit dans le message de groupe
de discussion : OR************* *@TK2MSFTNGP03. phx.gbl...
>I've already tried to do something similar, but for some bizzar reason the record lenghts in the vb are different to the so called equivalent in the net and without knowing the reason why the chances of getting the correct data back (even if it doesn't give an error) are pretty remote
"Patrice" <http://www.chez.com/scribe/wrote in message news:BA******* *************** ************@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************ ***@nothing.com a écrit dans le message de groupe de discussion : #6************* *@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:9F***** *************** **************@ microsoft.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************ ***@nothing.com a écrit dans le message de groupe de discussion : uF************* @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************ ***@nothing.com wrote in message >news:%2*** *************@T K2MSFTNGP06.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 >>togethe r 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************ ***@nothing.com wrote in message >>news:e%** **************@ TK2MSFTNGP03.ph x.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 >>>differen ces 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. 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 >>>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 >>>everythi ng i try to do in this turns out to be a nightmare - >>>perhap s i'm just too old and fixed in my ways >>>> >>>> >>>"Patrice " <http://www.chez.com/scribe/wrote in message >>>news:51* *************** *************** ***@microsoft.c om... >>>>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 >>>>array s are storing data using the same ordering). >>>>> >>>>Anoth er option would be to compute the record length >>>>(Runtim e.InteropServic es.Marhsl.SizeO f(GetType(Short ))*x.Length) >>>>> >>>>Anoth er 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... >>>>> >>>>-- >>>>Patri ce >>>>> >>>>"John " <no************ ***@nothing.com a écrit dans le message de >>>>group e de discussion : uh************* *@TK2MSFTNGP05. phx.gbl... >>>>>Hi >>>>>> >>>>>This .net is driving me crazy!! >>>>>> >>>>>In VB6 I had a type which contained a couple of multi-dimentional >>>>>arra ys 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: >>>>>> >>>>>Struct ure 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: >>>>>> >>>>>> >>>>>redi m x.array1(10,10, 2) >>>>>redi m 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 >>>>>struct ures with openfile and random access? Why does vbfixedarray >>>>>only allow 2 dementions????? >>>>>> >>>>>Chee rs >>>>>John >>>>> >>>>> >>>> >>> >> >
Try :
Structure SatLocation
Public origin As Short
Public _locationfixed As Short 'Boolean
Public _timefixed As Short 'Boolean
Public numberofsets As Short
<VBFixedArray(1 01 * 11 * 3 - 1)Public _xcoords() As Single
<VBFixedArray(1 01 * 11 * 3 - 1)Public _ycoords() As Single
Public stamp As Date
' Expose _ members as properties (see previous post for 3D arrays)
' TODO
End Structure
If I write a single record in VB6 and in VB9 it produces the same size on
disk. Members beginning with _ should be exposed using a property (seems the
cullprit were boolean values that are not using the same size)...
BTW I'm not sure what exactly are xcoords and ycoords but they could be
perhaps replaced by something that would be the same overall size but that
could be more handy such as an array of structure especially for the later
component. What are those 3 last values. Are they more handy addressed by an
index array rather than by a name (i.e. it could be MyCoords(100,2) .x,
MyCoords(100,2) .y, MyCoords(100,2) .z and could be exposed also as
MyCoords(100,2) .XYZ(0) if really needed the you would likely fit the 2 D
array limitation and wouldn't need any more the "exposed as a propery"
workaround....
Hope it helps.
--
Patrice
The actual text of the failure is: Offset and length were out of bounds for
the array or count is greater than the number of elements from index to the
end of the source collection.
"Patrice" <http://www.chez.com/scribe/wrote in message
news:e0******** ******@TK2MSFTN GP06.phx.gbl...
Works here . Are they fixed array VB 6 side ? I've seen in the doc that a
prefix is written or not depending on the exact type of the variable. For
example if you write a single record using VB6 what is the exact size of
your file in bytes ? (mine is 48 that is 2 elements*3 elements *4
elements*2 bytes).
Byte alignement could also come in to play and it's also possible to
control this
(http://msdn.microsoft.com/en-us/libr...e(VS.80).aspx).
Also be aware of your "option base" (do I remember ?). Are VB6 array 1
based or 0 based. They are always 0 based in VB.NET....
I'm quite confident it can be done, I'll try to give this a closer look
later with your structure layout...
--
Patrice
"John" <no************ ***@nothing.com a écrit dans le message de groupe
de discussion : OR************* *@TK2MSFTNGP03. phx.gbl...
>I've already tried to do something similar, but for some bizzar reason the record lenghts in the vb are different to the so called equivalent in the net and without knowing the reason why the chances of getting the correct data back (even if it doesn't give an error) are pretty remote
"Patrice" <http://www.chez.com/scribe/wrote in message news:BA******* *************** ************@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************ ***@nothing.com a écrit dans le message de groupe de discussion : #6************* *@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:9F***** *************** **************@ microsoft.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************ ***@nothing.com a écrit dans le message de groupe de discussion : uF************* @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************ ***@nothing.com wrote in message >news:%2*** *************@T K2MSFTNGP06.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 >>togethe r 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************ ***@nothing.com wrote in message >>news:e%** **************@ TK2MSFTNGP03.ph x.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 >>>differen ces 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. 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 >>>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 >>>everythi ng i try to do in this turns out to be a nightmare - >>>perhap s i'm just too old and fixed in my ways >>>> >>>> >>>"Patrice " <http://www.chez.com/scribe/wrote in message >>>news:51* *************** *************** ***@microsoft.c om... >>>>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 >>>>array s are storing data using the same ordering). >>>>> >>>>Anoth er option would be to compute the record length >>>>(Runtim e.InteropServic es.Marhsl.SizeO f(GetType(Short ))*x.Length) >>>>> >>>>Anoth er 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... >>>>> >>>>-- >>>>Patri ce >>>>> >>>>"John " <no************ ***@nothing.com a écrit dans le message de >>>>group e de discussion : uh************* *@TK2MSFTNGP05. phx.gbl... >>>>>Hi >>>>>> >>>>>This .net is driving me crazy!! >>>>>> >>>>>In VB6 I had a type which contained a couple of multi-dimentional >>>>>arra ys 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: >>>>>> >>>>>Struct ure 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: >>>>>> >>>>>> >>>>>redi m x.array1(10,10, 2) >>>>>redi m 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 >>>>>struct ures with openfile and random access? Why does vbfixedarray >>>>>only allow 2 dementions????? >>>>>> >>>>>Chee rs >>>>>John >>>>> >>>>> >>>> >>> >> >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vladimir Khvostov |
last post by:
Hi,
We have some DB2 table on the host that has varchar(3200) columns that
are used to store binary data (I know that "varchar(3200) for bit
data" should have been used, by modifying host table is not an option
at this time).
I wrote a Win32 application, which is using DB2 Connect and ODBC to
pull the data from the host. I am passing SQL_C_BINARY as a 3rd
parameter in SQLBindCol() call, ::SQLBindCol(hStmt, nColNo + 1,
SQL_C_BINARY,...
|
by: Bjørn Augestad |
last post by:
Below is a program which converts a double to an integer in two
different ways, giving me two different values for the int. The basic
expression is 1.0 / (1.0 * 365.0) which should be 365, but one variable
becomes 364 and the other one becomes 365.
Does anyone have any insight to what the problem is?
Thanks in advance.
Bjørn
|
by: Steve Gough |
last post by:
Could anyone please help me to understand what is happening here? The
commented line produces an error, which is what I expected given that
there is no conversion defined from type double to type Test. I
expected the same error from the following line, but it compiles fine.
The double is silently truncated to an int and then fed in to the
implicit conversion operator. Why does this happen? Is there any way
that I can keep the implicit...
|
by: Steve Richter |
last post by:
here is a warning I am getting in a C++ .NET compile:
c:\SrNet\jury\JuryTest.cpp(55) : warning C4927: illegal conversion;
more than one user-defined conversion has been implicitly applied
while calling the constructor 'MyString::MyString(const
wchar_t *)'
c:\SrNet\jury\JuryTest.h(21) : see declaration of
'MyString::MyString'
The class "StringData" uses a, whatever you call it, operator const
|
by: VB Programmer |
last post by:
Simple ASP.NET 1 site. Opened solution in beta 2 of 2.0. Ran thru
conversion wizard and it states:
"Conversion Complete. There were some errors during conversion."
I view the conversion log and for the project there is 1 error...
http://localhost/Watersmark/
Conversion Issues - http://localhost/Watersmark/:
ERROR: Failed to backup website http://localhost/Watersmark/
| |
by: Påhl Melin |
last post by:
I have some problems using conversion operators in C++/CLI. In my
project I have two ref class:es Signal and SignalMask and I have an
conversion function in Signal to convert Signal:s to SignalMask:s. The
reason is I have a free function called WaitSignal that accepts av
SignalMask where Signals parameters are supposed to implicitly be
converted to SignalMask:s. I'm using the SignalMask class because I
want to be able to supply a logic...
|
by: Richard G. Riley |
last post by:
Would it be wrong to use "implicit casting" instead of the standards
"implicit conversion" when talking about implicit conversions between
certain data types. The standard mentions "explicit conversion" for a
cast operation
|
by: Dhirendra Singh |
last post by:
Hi,
The following C++ program is not compiling on my system.
#include <iostream>
using namespace std;
class complex {
double re, im;
public:
complex( ) :re(0), im(0) {}
|
by: Coleen |
last post by:
Hi All :-)
I'm new to this site. I've been trying to convert several .Net 2003 web applications and getting tons of conversion errors.
I found this site to help walk me through the conversion process: http://webproject.scottgu.com/VisualBasic/Migration2/Migration2.aspx
which is great, however, when I follow the steps in this tutorial exactly, I get 102 conversion errors! Almost all the errors have to do with ambiguous file names, but...
|
by: Nikola |
last post by:
Hello,
I'm writing a String class for C++ and I'm getting the following error
message when using operator:
test.cpp: In function ‘int main()’:
test.cpp:7: error: ISO C++ says that these are ambiguous, even though
the worst conversion for the first is better than the worst conversion
for the second:
string.h:19: note: candidate 1: char Types::String::operator(unsigned
int) const
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |