Final Post of the day

M

Miro

Im trying to store data as I would in some old language.

Old Example
//Create an array that holds 3 different variable types

TempArray := { { "Hello", 1, False }, { "Goodbye", 123, True } }

( basically array 1 is a char, 2 is a number, and 3 is a bool )
So
TempArray[ 1, 1 ] == Hello
TempArray[ 1, 2 ] == 1
TempArray[ 2, 2 ] == 123


How can I set something like this up in Vb.Net 2003 ?

Or Can I ?

I have looked at ArrayList and havnt found an answer there. Im not sure
what to "search" for or what im looking for to declare this.

Thanks in advance,

Miro
 
C

Cor Ligthert [MVP]

Miro,

And you want it exactly with that ?
TempArray := n { "Hello", 1, False }, { "Goodbye", 123, True } }

Otherwise in 2.0 the list (of T) with a class it is very easy to handle
this.

Cor
 
G

GhostInAK

Hello Miro,

A class that has 3 properties (say: .Greeting, .IntValue, and .BooleanValue)..
then create an instance of the class for each array element. You can then
use an ArrayList or a Collection(Of T).

-Boo
 
R

R. MacDonald

Hello, Miro,

Or, if you don't require typing for the individual columns, you could
even just write:

Dim TempArray(,) As Object = {{"Hello", 1, False}, _
{"Goodbye", 123, True}}

Cheers,
Randy
 
M

Miro

It was the simple example to post on thew newsgroup.

Basically my point of this is this:
This is for the case of my db file ( created by code as well.)

So what i basically want to write is a Procedure that will store a coded
array ( by me / hardcoded ) and it will look something
like this: ( example ) - again written in non vb code...

EmployeeArray := { { "Code", "C", 10 }, ; // Code field Character of 10
{ "Name", "C", 30 }, ; //Name field Character of 30
{ "Age", "I", 3 } } //Age field Integer of 3

and do this for all the tables required in the db file.

That way, if in a new version a db file is changed ( not sql ) ...no update
is really required to do another
install. All you have to do is supply the new exe, and On Load of the VB
code, the program checks
to see if the DB file is there...and tries to see if it can add any / "all"
of the fields.

If the field exists, you get around this by catching the exception, and
continuing on.

Simple solution to users who really dont know what a folder is / file is /
and have enough trouble getting around an install.

This also saved me once from another situation I had. ( in a program
written other than vb ).
The exe was being locked by the network somehow and could not be replaced.
Somewhere a user was using it, or
windows kept it locked and rebooting the server was not an option at the
time. So by creating an exe, that
reads an INI file, and from that INI file it loads a new EXE ( and closes
itself ) all I had to do in that case was to
email the user a new EXE named file with a new INI file. User copies that
into the directory, and any new user
logging in gets the new exe. The server could be rebooted later.

Loading.exe -> reads ini file where INI file has a value of (
"AProgram.exe" )
so Loading.exe runs AProgram.exe and Loading.exe closes.

Anyones shortcut ( if using over the network ) should point to the
Loading.exe
So if a change is required, I can send them AProgramB.exe and an INI file
that contains "AProgramB.exe" and
all the user has to do is copy this into a folder.

Any new user who is not running a program taht takes a long time to data
crunch can log in, and on login, it adds
new fields as required ( if required ), and the old user who is data
crunching does not need to boot off his computer.
A company does not need to wait for 1 user to do an update.

A network guy can schedule a reboot on the server ( if required ) when he
wants to - not when I want / need to.

This has worked great for a user who wants a new report in the system
Pronto, or a new field or something they would
like to have written in the db. Send them a quote - quote accepted...write
the new app, send them the new INI and EXE
file, and the big boss is happy. Any new user logging in will start writing
to the new fields, any old user can finish the day without
knowing anything different. A proper update can be installed later - that
also clears away the old unused EXE's.

My original app idea will not be ( most likely ) run thru a network. It
will be stand alone copies. But in the future
it could.

Anyway, thats the theory ( and it works great ) of why set up your file defs
in an "array" so you can create them / check
them at start up.

** I would be curious to know how some of you other programmers do this?
Keep in mind the app example I
am giving you could have 25+ or 50+ users in all at the same time.

I have finally decided i will be staying away from sql express until the
original app is written. Then the next learning experience
will start.

Miro


R. MacDonald said:
Hello, Miro,

Or, if you don't require typing for the individual columns, you could even
just write:

Dim TempArray(,) As Object = {{"Hello", 1, False}, _
{"Goodbye", 123, True}}

Cheers,
Randy

Im trying to store data as I would in some old language.

Old Example
//Create an array that holds 3 different variable types

TempArray := { { "Hello", 1, False }, { "Goodbye", 123, True } }

( basically array 1 is a char, 2 is a number, and 3 is a bool )
So
TempArray[ 1, 1 ] == Hello
TempArray[ 1, 2 ] == 1
TempArray[ 2, 2 ] == 123


How can I set something like this up in Vb.Net 2003 ?

Or Can I ?

I have looked at ArrayList and havnt found an answer there. Im not sure
what to "search" for or what im looking for to declare this.

Thanks in advance,

Miro
 

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

Top