Python - Choosing A Data Structure In Performing Comparison?

Jan 14, 2011

I'm a Python programmer and VB.NET newbie converting an application from Python to VB.NET (3.5).In Python, I have a function which returns a list of tuples which I run on two datasets with results like this:

data1 = [(1,"a",2),(5,"c",7)...]
data2 = [(1,"a",2),(5,"x",7)...]

Then I want to check if the two data sets are identical.In Python I check for equality like this:

"Equal" if data1 == data2 else "Not Equal"I want to know the easiest way to structure the data in VB.NET.

It looks like the right data structure for each data set in VB.NET is a List(of Something).

Should I create a Class to hold each data item, or is there a simpler way? If I do, will I need a custom way to decide if two instances hold the same data? What is the easiest way to compare the two data sets for equality?

View 2 Replies


ADVERTISEMENT

Structure/component For Performing Complex Calculations?

May 24, 2010

I hope this is the right forum. I've been developing something for a while now, and I've hit some walls with the direction I was going. I'm not an expert in .Net, so I was hoping maybe there's a nice solution that I had no idea of its existance.

A little bit of background: I'm building a relatively large scale calculation component which used to be in a spreadsheet. It composes of about 1300 values, about 150 which are passed in to the component, and the remaining 1150 are calculated based on these inputs. However, these values can be in multiple rows, as in there will be multiple rows of these 1300 values. Aggregate calculations need to be performed on these rows on a regular basis. Right now I'm using a dataset to perform this since it supports multi-row calculations nicely, but it has its limitations. It doesn't support some of the mathematical functions that I need it to perform (such as exponential) and performing a calculation like a weighted average is a hassle because you need to add a new field for it. Furthermore it doesn't let you use custom variables in your expressions, so if you want to create an on/off switch for something you need to create a single row table and set up a relationship to it. Also I'm getting tired of the dataset designer being riddled with bugs, and it's obvious to me that it was not meant for calculations of this magnitude. Not being able to see the data type of the field in the designer is a minus too (you have to bring up the property window on that field). I looked in to just creating classes to perform this, but the problem is that it needs to be relatively dynamic, and the calculations need to refresh based on user inputs. The best way I can think of doing this is setting up the 1150 calculated variables as properties so that they will be calculated automatically. But, I'm afraid that this is going to fire off thousands of calculations each time any variable is accessed, which is going to be a rather significant performance hit.

So, my question is whether anyone knows of a good structure or component that I could use to achieve my goals. I apologize if I didn't do a very good job explaining my situation, so I'll try to elaborate on any of my explanations if anything is unclear.

View 5 Replies

Class - Internationalization In .Net : Choosing The Right Structure Type?

Jan 22, 2010

I'm about to start translating my vb.net application, and I don't want to use the default methods provided by Visual Studio to do so. I need my application to be very light, and it nearly doubles it size to use the resources option.Therefore, I'm planning to use some thing like a class, of which I would have one instance per language. Since I don't want to distribute language files as separate files (I'd rather have them hard-coded), I would like to find an easy way to check if every field of the class is initialized. I was thinking of something like an Interface, where I would do something like this:

Public Interface Language
Dim HelloMsg As String
Dim GoodbyeMsg As String
End Interface

[code]....

It's obviously not the right way to do it (although I could use properties instead of vars), but I was wondering whether the was a way to have the compiler check that everything is translated and warn about it if not.

View 2 Replies

Python To VB: Unknown Data Types

Mar 3, 2010

I never thought I'd say this, but I am getting pissed at how easy it is to just plop down a variable in python without any declaration. I have an existing python script which interfaces with a server, and it builds its own messages to be communicated via sockets. What I am trying to do is take the command line python script and convert it into a VB GUI app that is more user friendly.

[Code]...

View 11 Replies

Large Files For Data Comparison?

Sep 21, 2010

I am working on a program for a customer and am working in VB2010 in VB language. I have two rather large files that contain data. File #1 is over 300,000 lines of data. File #2 is over 100,000 lines. The files are CSV text files. On a User Form, there are two values, "StartTime" and "StopTime". This is the process I am doing:

1. Read both files into ArrayLists
2. Get item #1 of ArrayList #1 (we'll call this "A")
3. Get item #1 of ArrayList #2 (we'll call this "B")

[code]....

View 6 Replies

Get Column Data Type In Datagridview For Comparison?

Dec 15, 2009

I am writing validation for a datagridview which may open a number of different tables (dependant on what the user selects). The idea is that the user will select a lookup table to edit or add too, the datagridview opens (via a binding source) and populates itself with a specific table's data.

The user can then edit the data in the rows and when they are happy update the dataset which in turn updates the database table.

This all works except there is no validation per say prior to the update. As the datagrid loads a different table dynamically I cannot predetermine table column names (without writing a mass of hard coded values) so I would rather go by the datatype of the column since the tables all follow a similar format.[code]...

View 3 Replies

Variables - Combining Multiple Data Types Into A Single Unified Data Structure

Mar 16, 2012

In VB.NET I would like to create a complicated data structure with multiple types of data stored in an array like format (see below). I am trying to create a data structure that would look something like this: [Name; xLoc; yLoc; zLoc; [Jagged Array]] Note: Name needs to be dimensioned as a string, xLoc and so forth as integers. The Jagged Array would look like this:

[Code]...

View 1 Replies

Need Right Data Structure

Jun 22, 2010

I have a list of a few thousand names. I actually have last name, first name, phone number, etc and more info. I'm going to make a class to contain the data. so I'll have like a people object with for example a last name field. I'm going to store these in like an array list. Lets say i have 100 items in array list. Maybe last name smith is on index 3 21 and 63. I'd like a data structure where i can easily search for smith and get indexes 3 21 and 63. Brute force is simply loop through complete array checking last name and grabbing index each time i find smith. Ideally id like to have more efficiency. In c++ I'd use a multi map but i don't see that that exists in vb.net. A dictionary wont work because its 1:1.Name of data structure, short description of how to use it and web help reference page would be nice.

View 2 Replies

Use Data Structure In VBA ?

Feb 14, 2008

I would like to use data structure in VBA. the code like

Public Structure employee

Public firstName As StringPublic middleName As String

End Structure

But there was compile error: Expected :end of statement. Can I use data structure statement in this way? how to use data structure in VBA?

View 4 Replies

Changing Data In A Structure?

Nov 25, 2009

I have some structures and I change the data inside a loop. This works ok. But as soon as the method ends, all values in the structure are reset???

Heres my

Private Sub ReadDevice(ByRef device As Device)
Console.WriteLine(" Reading device " & Device.name)
Dim data As Short

[Code].....

View 5 Replies

.net - Data Structure For Text Adventure?

Nov 6, 2011

I'm designing a choice based adventure game in VB.NET 2010, where you are presented with a story label, and you choose between 2 buttons, which choice you want to make. I want to know the most efficient way to do this.My goals are to store the labels for the buttons and the story in some form of data structure, which is temporarily a hash table right now, and some form of structure for the choices. Right now I am using a custom class that references the indexes of the next 2 choices and their respective label indexes which stores the class instances in a hashtable.I've looked into things like arrays, dictionaries, lists, and collections, but I'm not sure which one best fits what I'm after. Any .NET data structure would work. What is the most efficient data structure for these 2 pieces of data? Would just a string array work?

View 2 Replies

Calling Function On DLL To Get Data From Structure?

Apr 16, 2012

I have problem about how I call a function on DLL to get data from a structure. Have a C++ example about how it's works the library, and I want to use it on vb.net. his is the working c++ example:

Declaration:
BOOL (WINAPIV* MyFun)(DWORD start1, DWORD stop1, P_RESULT pResult, PDWORD pTpNum, myCALLBACK lpFunc) = NULL;

Call:
// pStruc = RESULT structure
// TrpNum1, TrpNum is ULONG
ULONG TrpNum1=0;
MyFun(Start,Stop,pStruc+TrpNum,&TrpNum1,&myCB);

Callback:
void __stdcall myCB (RESULT *pStruc) {
printf ("%.3f", (double)pStruc->val1);
tpn++;
[Code] .....

The error is this: "Attempted to read or write protected memory. This often indicates that other memory is corrupt."

View 1 Replies

Fill A Structure With Data From A SQL Table?

Feb 7, 2011

Is there an easy way to get data from a table in SQL Express and put it into a Structure? The table has one string column and five bit columns. I'm using VB.net

View 13 Replies

How To Pass Structure Into A Data Layer

Feb 19, 2011

I'm creating a Data Layer for a Web Application and in one of my functions, I need to pass in a Structure full of Customer info. This Data Layer is essentially a DLL. My problem is that I'm not sure how to do this.Below is my code and what I want to do.

[Code]...

View 5 Replies

Integer Data Type Is Structure?

Mar 7, 2010

Is the integer data type is structure? And if yes what is the original code of it?

View 2 Replies

Store Data In An Array Using A Structure?

Jun 6, 2011

im tryin to store data in an array using a structure. However, the code im using keeps returning a null referece exception, even when there is something in the input boxes. This is the code im using:

With SaveInfo(Index)
.EmployeeID = EmployeeIDComboBox.Text
.EmployeeName = EmployeeNameBox.Text

[Code].....

View 6 Replies

Structure For Large Quantities Of Data?

Jul 3, 2010

I have a large amount of data (400 variables recorded 2 times per second) which is output from a factory monitoring system. It is stored in encrypted files in blocks of one hour from which i can extract to csv with a small piece of software.I would like to upload these csv files into a single database from where i can make graphs, analysis or whatever over longer periods.

The csv files have one line of data per 'time stamp', each of which can be conceptually segregated into approximately 15 individual pieces of equipment.I can quite easily import the data into a single table. However, i find that, very quickly, i end up with an enormous file (about 700mb/month) which is extremely ponderous to work with.

is it possible to split the table into 15 separate tables related by 'time stamp' and second, can each of these separate tables be saved in separate files in storage memory (such that only the files with the desired data are imported into ram).

View 13 Replies

Structure Inside Another Structure Receives Null Reference Error?

Jan 5, 2012

Module Module1
Public Structure structure1
Public TRANS() As structure2
End Structure
Public Structure structure2
Public X() As Integer
End Structure
End Module

View 17 Replies

Array In Structure Apparently Not Retaining Data?

May 6, 2012

I have a structure with 6 arrays inside it that is serializable so I can save the arraylist of them to a file and load them from the file. This part works.

When loaded from the file the data from a single specific record is populated to a listview control, this works on form load. The user can then select different records and in theory display the data in them (specifically the stuff in the arrays).

Displaying the data works as I'm editing the data, and on first load of the form and displaying the "default" record from the structures. Any other time (trying to switch between records during editing or after loading) the record is pulled (as shown by stepping through the code line by line) but the data in the arrays in the structure and only the data in the arrays is missing.

I've gone through all the code that runs and there is nothing that overwrites the array data in the records between displays so I'm at a complete loss as to why this data is going missing.

Below is the structure and the code.

Defined in a Module so as to be accessible when needed in several places through the program:

Public JBonus As New JobBonuses
Public JBonuslist As New ArrayList

On load to set dimensions to the arrays:

JBonus.Str = New Integer(999) {}
JBonus.Agi = New Integer(999) {}
JBonus.Vit = New Integer(999) {}

[Code].....

View 1 Replies

Array Structure With Values For Each Data Type

Nov 8, 2011

I epochly failed creating an array structure. How would I build it like I tried to do with values for each data type.

Structure PovertyGuidelines
Dim Id As Decimal
Dim NumberOfPersons As Decimal
Dim AnnualIncome As Decimal
End Structure
Private Data(20) As PovertyGuidelines
Private Id(,) As Decimal = {{1D, 2D, 3D}}
Private NumberOfPersons(,) As Decimal = {{6D, 9D, 7D}}
Private AnnualIncome(,) As Decimal = {{24000D, 32000D, 27000D}}

View 1 Replies

Asp.net - Preserve Data-structure On AJAX Postback

Dec 29, 2009

[Code]...

The first time the page loads my structrure is filled correctly. After an AJAX postback all the structure fields are setting to nothing. (It seems that the Dim OldPInfo As New PInfo is called again), but i should better ask the SO Experts.

View 1 Replies

Copy Data From One DataTable To Another With Diffrent Structure?

Apr 23, 2011

I am copying data from DataTable to another DataTable with a structure.I have to hardcode coulums number in the loop and copy the data in object array.[code]...

View 2 Replies

Data Structure Memory - System Resources

Feb 27, 2009

I was wondering if there was a way to find out how much memory a data structure too up. So say I declared a list of strings.
Dim theRN As New Dictionary(Of String, Integer)
Say it had 25 elements in it. How to find out how much memory those 25 elements are costing me?

View 3 Replies

Data Structure To Represent Bookable Timeslots

Apr 27, 2009

What suggestions do people have for a timeslot data structure? I have a number of activities and I'm planning to display them in a datagrid with days as columns and timeslots as rows. This suggests to me a timeslot data structure with 5 properties for the five days (the columns) for every value I want to use e.g. a timeslot ID and the number of slots left.

So.

Property Day1ID
Property Day1Slots
Property Day2ID
Property Day2Slots
Property Day3ID
Property Day4Slots
etc

Then each TimeSlot structure would be for a specific time. say 9:00 and another for each hour after that. Then I'd have a list of timeslot structures that will auto bind against the datagrid. I'm exploring new ground here and as you can see I'm not very clear on what/how to do it?

View 2 Replies

Extracting Data From CSV File Into Searchable Structure?

Jun 25, 2010

I have a csv file with 48 columns of data. I need to open this file, place it into a data structure and then search that data and present it in a DataRepeater. So far I have successfully used CSVReader to extract the data and bind it to myDataRepeater. However I am now struggling to place the data in a table so that I can filter the results. I do not want to use SQL or any other database.

So far, this is working in returning all records:
Private Sub BindCsv()
' open the file "data.csv" which is a CSV file with headers"
Dim dirInfo As New DirectoryInfo(Server.MapPath("~/ftp/"))
Dim fileLocation As String = dirInfo.ToString & "data.txt"
Using csv As New CsvReader(New StreamReader(fileLocation), True)
[Code] .....

View 2 Replies

Saving And Loading Data Structure Items

Jun 20, 2012

I am quite new to VB.NET and I am attempting to create a console application that can write, save, load and edit sets of data. Lets say I have something like this:

[Code]...

However, I have no idea how to load the data so I can manipulate it in the EMPLOYEE structure system. I am not sure if I have made my question clear enough, for as you can see I'm quite new to programming and am not essentially familiar with the terms of speech.

View 1 Replies

Take Data From A Text File And Place It Into A Structure?

Oct 8, 2010

Attempting to take data from a text file and place it into a structure.

Option Strict On
Imports System.IO
Public Class Form1
Structure Employee

[code]....

View 3 Replies

Class Structure - Large Structure That Has Lots Of Properties ?

Jan 5, 2010

I'm new to VB 2008 after having spent a long time with VB6, so I apologize if this is a stupid question. But I'd really like to have this straightened out.

Let's say I have a pretty large structure that has lots of properties.

Code:

Now say that I want an internal database with about 10 instances of this structure total, describing, say, 10 different products that a store sells. When these values are loaded from a database, they remain totally static. (However, they can be different each time a program loads)

Now say that I have a class. Each instance of this class is a type of that BaseProduct structure. Meaning, each instance of the class pertains to one of the 10 types of products that the store sells. However, this class has additional properties that pertain specifically to each instance, which are not static.

Code:

Now, the problem here is... If I have 200 different transactions, each one contains an instance of BaseProduct. BaseProduct is HUGE, and is largely redundant (only 10 types possible), so I think it's a little silly to include a whole copy of it with EVERY transaction. However, the Transaction class really needs information regarding the base product it pertains to. Is there a way to, instead of declaring a New BaseProduct in the Transaction class, to simply make one of the properties of the Transaction class a pointer to a BaseProduct variable?

In VB6, I would accomplish this by making a BaseProduct(10) array, and then giving each Transaction an ID number referring to an entry in that array. But in VB 2008, using class structure, this is impossible. I can't define the BaseProduct(10) array outside of a class in a namespace, and if I define it in the actual application's form, then the class loses modularity since it relies on the application that's using it.

View 11 Replies

Converting Structure Within Structure To Byte Array For Socket

Aug 29, 2009

I am trying to communicate with an external device and i am trying to send a byte array to the external device via sockets but i am always getting a response the message size is too small so i am not sure what i have done wrong. Between the data type there should be no alignment present and all numbers are represented in little endian format. The char array is not null terminated as mentioned in the protocol specifications.

I have to send data based on a struct that embeds 2 other struct. So here's my vb.net code for the struct used to convert to byte array and the sending part.

Public Structure MESSAGETYPE_OIP_Login
Dim Header() As COMMANDHEADER
Dim UserName() As PSTRING

[Code]....

View 2 Replies

Another Method To Reference The Array And The Member Of The Structure To Get The Data?

Jan 31, 2010

I have problems with array of structures.my structures are like this

structure order
xxxxxxxxxxx
yyyyyyyyyy
zzzzzzzzzzz
end structure

and then I created many array of structures, like this private arrayorder (100) as order

now i need to sort the entire xxxxxx member of the array of the structure with a function, but I dont want to use loops with arrays indexes to access the information. I want to know if there is another method to reference the array and the member of the structure to get the data.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved