Conversion Problem

J

John

Hi

This .net is driving me crazy!!

In VB6 I had a type which contained a couple of multi-dimentional arrays
which i used to create and read records:

Type AAA
:
Array1(10,10,2) as Integer
Array2(20,20,4) as Integer
:
End Type

I'm trying to get vb8 set up so that i can use the same files and use the
fileopen method to randomly access the file data etc

vb8 won't let me use <vbfixedarray> with more than 2 dementions so i cannot
declare it correctly in the structure declaration.

What i have done is:

Structure z
:
dim Array1(,,) as short
dim Array2(,,) as short
:
End Structure


Dim x as z
I have then tried to Redim in an initialation so:


redim x.array1(10,10,2)
redim x.array2(20,20,4)

But when i go to get the record length Len(x) it is totally wrong

Is there any way out of this mess so i can use my original record structures
with openfile and random access? Why does vbfixedarray only allow 2
dementions?????

Cheers
John
 
N

Nathan Sokalski

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.
 
J

John

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
 
J

John

thanks Patrice for that - i considered doing a fudge but the values are out
so there seems to be an overhead in the array structure differences in the
vb6 and vb8 - the 2 values do not come out the same anyway- they are a few
hundred bytes different so the chances of reading and writing correctly into
the old records is zero, and i don't fancy spending the rest of my life just
trying to fudge something that works.

i tried Runtime.InteropServices.Marshal.SizeOf(GetType(Short))*x.Length but
it just gives me an error saying length is not a member of x so i don't know
whether this would work or not!!

god i really hate this vb.net stuff - why is everything such a pain? -
nothing seems logical (for example, why have a vbfixedarray statement that
is limited to 2 dimentions?) and why they call it vb god knows, i've used vb
since the 70's without any problem everything i try to do in this turns out
to be a nightmare - perhaps i'm just too old and fixed in my ways
 
J

John

Ok i've got the Runtime.InteropServices.... bit to work

I've done it on all the elements of the structure and added them together
but i'm 4 bytes out?

I suppose i could just hard code the record length - but it seems a very
poor way of doing things.
 
J

John

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)
 
K

Ken Halter

John said:
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 <g> I use VB6 100% of the time at work
and home, so I actually get stuff done..

Just passin' thru
 
J

John

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.
 
J

John

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!
 
J

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 multidementional array aspect.

The vb6 type structure is as follows:

Type satlocation

origin As Integer

locationfixed As Boolean

timefixed As Boolean

numberofsets As Integer

xcoords(100, 10, 2) As Single

ycoords(100, 10, 2) As Single

stamp As Date

End Type

What I need to do is to be able to read and write to randomly to existing
data in the above record set that was created under vb6 - as you can see
there are literally thousands of cords that I certainly do not want to input
again, so basically I need to use the this same record set.
 
J

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
 
J

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.
 
J

John

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.
 
K

Ken Halter

Tom Shelton said:
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

....and he's not familiar with the framework because the help system sucks
like a hoover.
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

256... and we can see "2 doesn't apply" from the over-bloated, "feature
rich" (aka bug fest) apps people create with dotNet.
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)...

....and, you're saying that's not possible in VB5/6? If so, you may not be as
"great" as you assume.
Public Class MyForm
Inherits System.Windows.Forms.Form

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

Too bad that's not VB syntax. It's B#... I've been using basic and assembler
since 1981 and basic has *never* used curly braces. That's "C".... plus,
when the app is done, the code is readable in basic (and assembler)... not
that framework/linq/xml crap.... guess what... linq or any variant of SQL is
*NOT* part of any basic language that makes sense. That's SQL syntax and
should stay as such. No use adding hundreds of keywords to an already
over-bloated environment
..

Private Sub DoCoolStuff(ByVal btnIndex As Integer)
Dim theButton As Button = buttons(btnIndex)

Very readable.... NOT
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

....so, it worked. Which version(s) of the framework do your users need to
download? Microsoft surely doesn't make things easier on the developer. That
went away when VS6 did... and, if the whole mess is so freaking "wonderful",
why do they have to give it away free? You can still buy legit copies of
VS6, but be prepared to pay more than VS2008 costs... but, if you want what
you pay for, grab VS6

Even after... what... 7? 8 Years? No one knows what to call this "B#"... is
it VB.Net? is it VB#? How about B#? or maybe it's VB8? VB9? What ever. Have
fun.
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

Yeah... or maybe just write the thing in VB6 and go on to the next job, eh?

But, like I said... you guys can have these freaking groups.
 
J

John

OK i've got it to read a record in now, i'll play around with it and see
where the data is actually being held and can be written and read
 
J

John

The record holds spacial (2d and 3d) information on objects, i nearly put
the date time in as well as the 4th dimension. I will try your method of
accessing to see if that works ok - thanks for your help by the way. I may
use this as a temporary fix and use vb6 to read and write the information
into a different structure so i can use the vb8 more sensibly
 
L

Lloyd Sheen

Ken Halter said:
...and he's not familiar with the framework because the help system sucks
like a hoover.


256... and we can see "2 doesn't apply" from the over-bloated, "feature
rich" (aka bug fest) apps people create with dotNet.


...and, you're saying that's not possible in VB5/6? If so, you may not be
as "great" as you assume.


Too bad that's not VB syntax. It's B#... I've been using basic and
assembler since 1981 and basic has *never* used curly braces. That's
"C".... plus, when the app is done, the code is readable in basic (and
assembler)... not that framework/linq/xml crap.... guess what... linq or
any variant of SQL is *NOT* part of any basic language that makes sense.
That's SQL syntax and should stay as such. No use adding hundreds of
keywords to an already over-bloated environment


Very readable.... NOT

...so, it worked. Which version(s) of the framework do your users need to
download? Microsoft surely doesn't make things easier on the developer.
That went away when VS6 did... and, if the whole mess is so freaking
"wonderful", why do they have to give it away free? You can still buy
legit copies of VS6, but be prepared to pay more than VS2008 costs... but,
if you want what you pay for, grab VS6

Even after... what... 7? 8 Years? No one knows what to call this "B#"...
is it VB.Net? is it VB#? How about B#? or maybe it's VB8? VB9? What ever.
Have fun.


Yeah... or maybe just write the thing in VB6 and go on to the next job,
eh?

But, like I said... you guys can have these freaking groups.

Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem()
{Me.SongCounts, Me.CurrentlyPlayingTxt})

some code out of a designer.vb file. Now it may only be me the I see curly
brackets. Before you harangue people it would be best to check what you
say. This forum should be constructive not a place to thump your chest.

LS
 
K

Ken Halter

Lloyd Sheen said:
Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem()
{Me.SongCounts, Me.CurrentlyPlayingTxt})

some code out of a designer.vb file. Now it may only be me the I see
curly brackets. Before you harangue people it would be best to check what
you

Yeah... a B# designer file. How does that relate to my statement? I said
BASIC, in case you missed that... not this "C Wannabe"
say. This forum should be constructive not a place to thump your chest.

boo hoo. How about *you* reading more carefully before jumping in, eh?
 
L

Lloyd Sheen

Ken Halter said:
Yeah... a B# designer file. How does that relate to my statement? I said
BASIC, in case you missed that... not this "C Wannabe"


boo hoo. How about *you* reading more carefully before jumping in, eh?

As far as I know this is a VB.NET group and curly brackets are part of the
syntax. Grow up.

LS
 
K

Ken Halter

Tom Shelton said:
Please! And VB6's doesn't? MS help has sucked for years - fortunately,
there's this thing called the Internet....

Yeah... in dotNet, the internet is required. Not so for VB6 and its version
of MSDN.... but, it makes sense the internet's required since MS
specifically added .NET to the name. It's a web app generator. Now, if I
were creating web apps, or even apps for a mobile device, I surely wouldn't
use VB5/6... but for desktop apps I surely wouldn't want to use dotNet.
Duh, I said that was one of the reasons for control arrays? In VB.NET,
they
don't have to be a control array and they don't have to be the same type.
Or
are you claiming that you can have the same event procedure handle the
TextChanged event of a combobox and a textbox in VB6?

ummm... yes I am... I'm not sure why this is such a surprise. Have you never
coded a sub to be called from multiple places? What difference does it make
where the change event's coming from, or even what control fired it? If
that's so important, pass the control to the sub. No big deal. geez.
VB never had array or variable initialization on the same line before
either... A feature was added, and a syntax was chosen. Get over it.

Yeah, because it makes the code unreadable. My enter key works perfectly and
I use it all the time.

Dim i As Integer : I = 10 'is perfectly valid code in VB3,4,5,6 but no one
uses that syntax because it's unreadable and (or should I say AndAlso) leads
to bugs.

While I'm at it, this "+=" and similar crap they've added to make C
programmers more comfortable. What a mess that is. I can't believe people
would rather save 2 freaking keystrokes than have easy to read code... but,
I guess when you're in dotNet, every keystroke you can save counts, right?
You don't like LINQ - don't use it.

Thanks for the option... Don't like dotBloat either... so I don't use it.
HTH
Your oppinion.

Mine and about 5 million others, yep.
What? As opposed to:

Dim theButton As Button
theButton = buttons(btnIndex)

Sorry, but I think I like the one line rather then two bit.

If that was supposed to be VB syntax, you forgot the Set keyword.. the code
you posted would attempt to pass the default property of those controls back
and forth.

Set theButton = buttons(btnIndex)
Which ever version my app needs. That's sort of a stupid question - how
many
Visual Basic runtimes are there? Oh, yeah one for every version.... And,
well were at it lets have a discussion about binary compatability, and dll
hell.

Check these groups. How many people say they've set their app for 2.0 but
the installation forces them to install 3.5?

If you're having problems with Binary Compatibility and DLL Hell after all
these years, I'm very sorry. Most of us have figured out how to deal with
those problems.
They give it away for very good reasons. VS's current competition is
almost
all FREE. It's a market difference, and not a reflection on the quality
of
the product.

In your opinion.
LOL... Yeah right. VB6 was a great tool in it's day, but compared to
.NET
it's a toy. To do anything of more then average complexity requires
jumping

A toy... yep. One that helped MS "rule the world" in the 90's. btw, try
pasting a block of text in anything resembling an immediate window... what
do you see? What ever it is, it's not what you pasted... now try selecting
that block and pasting into the code window... didn't work at all, you say?
Didn't think so.

Now, try looking at only one procedure in your app.... collapse everything
yet? Can you name a single app in the world that requires its users to edit
text in a treeview? Without an option to turn it off? How about an option to
view a single procedure at a time, without jumping through those dreadful
hoops. Ain't gonna happen? That's because the design team doesn't care. It's
their way or the highway.
through some major hoops, which often if not done properly lead to crashes
and
hard to find instabilities. I can't tell you how often I read posts over
in

Hard to find instabilities... and you're questioning someone elses coding
abilities? mmmkay. What ever... btw... in the computer world, if *anything*
isn't "done properly", you'll get the same results.
the classic group that have long complicated answers delving deep in to
the
API, that are solved in .NET apps in a couple of lines of code. But, if
you
like dealing in complexity (aka bug riddled apps) then by all means, keep
clinging to your out of date toy environment...

Thanks for that. I appreciate that you've allowed me to continue to work in
VB6... what happened when Vista was released? Oh yeah... people were forced
to throw their pre-2005 dotNet stuff away... VB6 still has support until
Win2008 server dies... what is that... 12 more years?

Wasn't Vista supposed to be "The dotNet OS"?... yeah, 2% dotNet, if that.
Thank you, your too kind.

You're welcome... ya' know... after all of the dotNet trolls going to the
VB6 groups and spouting their "evangelist" crap, I thought you guys might
want some of the same medicine... I'll pop in and rattle a few cages now and
then.... that is, if you don't mind... if you do mind, I can show you how to
block senders, if that helps.

It still cracks me up that Delphi and COBOL code can run nearly unchanged in
dotNet, yet VB code can't.... shouldn't really be a surprise though, since
Anders Hejlsberg had probably never seen VB and Paul "I'm the father of VB"
Vick has never touched pre-dotNet VB code at all. The blind leading the
blind. Simple as that.

Have fun... check in next week... same time, same channel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top