Re: tables



RobcPettit@xxxxxxxxxxx wrote:
[...] In excel Ive got 4 small tables (9x9), which I use
vba to sort the data and allocate to the correct table. [...]
The next stage is to
bypass excel altogether and have the data within the application
itself.

In code, it seems like a single-dimensional array of 4 2-dimensional arrays would be fine. For example, assuming your data is floating point doubles:

double[][,] tables = new double[][,] { new double[9,9], new double[9,9], new double[9,9], new double[9,9] };

There are lots of other ways to store the data as well. Which is truly best depends somewhat on how you actually want to use the data.

I wouldn't use a Datagrid unless there was some specific functionality in the Datagrid that you specifically needed. Just because you were using Excel before, that doesn't mean that the data needs to be in any sort of Excel-like object when it's entirely contained within the application.

As far as saving goes, you have a variety of options, but one of the simplest is to put the data in your applications settings and use the Properties.Settings.Default class to read and write them. That way your code only has to deal with the in-memory representation, and all of the serialization is handled for you.

The array of doubles won't automatically serialize, so probably the best thing to do there is write some custom code that writes to a StringWriter based on a StringBuilder, and then save the resulting string in the application settings. Then you can reverse the process, using a StringReader to parse data from the string retrieved from the application settings.

If you use XML, you can use the XmlWriter and XmlReader classes to format the data as XML when saving and parse the XML when reading it back in.

All of the above can work using StreamWriter and StreamReader with a file instead.

Basically, once you've figured out what format in which you want to store the data, you should be able to store that to a file or to the application settings, however you prefer. You have a small amount of data and there may be some benefit in leaving it human-readable, so IMHO converting the data to text and saving it that way would work well. But there's no requirement that you do it that way if you feel a different format would work better (though, storing it as text does make the application settings method easier).

Pete
.



Relevant Pages

  • Re: VB6 LISTBOX problem
    ... Have a look at the code below, can you do a sort that is faster ... There are of course all sorts of ways of sorting stuff, especially stuf that is "linked together" as in your UDTs, but to prove the following code sorts it in exactly the same way that your own original code does so, by concatenating all three items of each element into a composite string exactly as you are already doing, but instead of dumping those composite strings into a ListBox it dumps them into a VB string array. ... Private Type SAFEARRAY1D ... Dim StPtr As Long, VAs String, pVAs Long ...
    (microsoft.public.vb.general.discussion)
  • Re: Deployment + Vista
    ... The problem is it's connection string is always hard ... Server settings form. ... guess it's a good thing I do not use that for settings. ...
    (microsoft.public.dotnet.framework.adonet)
  • C Sharp sorting considered superior to C by an order of magnitude
    ... following sort algorithms and the following points. ... its own comparision for the types bool, byte, short, int, long, ... single, double and string. ... private CheckBox CHKdeterminism; ...
    (comp.programming)
  • Re: Cant Figure Out How To Sort On Bind
    ... The sort order is not being passed as an argument, ... with the string "searchCache" to create a key for it, ... 'Assign ColumnOrder to ViewState ... Sub GetDataReader(ByVal ColumnOrder As String) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Reverse order file dialog box
    ... UserPreferencesMask is another one that uses multiple bits for many settings. ... mainly sort order. ... Ctrl + Close saves folder settings. ...
    (microsoft.public.windowsxp.basics)