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
ADVERTISEMENT
Feb 8, 2011
I have created a Class Library (dll) with a module and a class in it.The module declares a structure, and an instance of this structure.In the class, there is an arraylist declared.My main program calls a function in the class library class. The class calculates data, stores it in the instanceof structure. Then adds it to the arraylist.When i want to use this data in my main program, i get a Cast void error. Its because The structure of the data in the array if of the structure in Class Library module. Is there a way to change the structure of this array to an identicle structure in the main programs Module. When the function returns the arraylist I have tried storing it in a tmp arraylist and copying, cloning etc the data into another arraylist in my main program. still not working. Do i have to loop through all the data and copy each value to a new instanceofstructure, and store this in the new arraylist?
View 3 Replies
Jun 24, 2009
How do I change the program path '"logic.txt", "G:"' in the code below to theOpenFileDialog.FileName? Cos when I tried it, I receive String conversion errors and I tried altering the codes but it didn't work out well
vb.net
Sub Button1Click(ByVal sender As Object, ByVal e As EventArgs)
Dim sb As New StringBuilder(260)
[code]......
View 1 Replies
Apr 6, 2011
I have a question that I really hope someone can shed some light on for me, as this is driving me crazy trying to figure this out. Consider this code..
'declare and allocate
Dim lstNumbers As New List(Of Integer)
Dim nCount As Integer
[code]....
View 4 Replies
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
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
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
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
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
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
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
Mar 7, 2010
Is the integer data type is structure? And if yes what is the original code of it?
View 2 Replies
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Feb 20, 2010
I want to create a user defined data structure, which will be a 2 dimensional array such that each individual square of this 2-dimensional array will also store the score and the grades. ( Iam using VB.NET)
More details: for example: There is an 2 dimensional array with 3 columns and 2 rows, I want to fill each of the
[Code]...
View 2 Replies
Mar 13, 2009
Here is the:
Imports System.Data.OleDb
'Add reference to Access then
Imports Microsoft.Office.Interop
Imports Microsoft.VisualBasic
[CODE]...
I am using this to copy tables in an Access database(2003). the questions I have are:
1. How can I make this more 'obejct oriented'?
2. How can I copy just the structure of the tables and not the data?
(Currently both are occuring)
View 3 Replies
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