i'm using vb.net application program. i need to create a memory structure like this.
<Collection>
<uniqueID ID="100">
<Item itemno="0" desc="coffee" />
<Item itemno="1" desc="tea" />
<Item itemno="2" desc="milk" />
'
'
'
'
</UniqueID>
<uniqueID ID="200">
<Item itemno="0" desc="cup" />
<Item itemno="1" desc="plate" />
<Item itemno="2" desc="spoon" />
'
'
'
'
</UniqueID>
</Collection>
or a memory structure like this.
[100]-->[0,Cofee]-->[1,Tea]-->[2,Milk]
[200]-->[0,cup]-->[1,Plate]-->[2,Spoon]
when ever i receive a message i need to add that message to this kind of formatted memory structure. The message i receive will be in this format.
for example 1: "100,0,Coff ee"
for example 2: "200,1,plat e"
for the first time while i run the program for example i receive a message like "100,0,Coff ee". then 100 is the UniqueID for that message. so i need to create a header name 100 and put the message (0,Cofee) under that header. after that if i receive a message like "200,0,cup" . then 200 is uniqueID for that message. so i need to check whether header 200 is already exist in that memory structure, if not then create a header name 200 and put the message (0,cup) under that header. after that if i receive a message like "100,1,tea" . then need to check whether header 100 already exist in that memory structure, if exist then add the message (1,tea) under the uniqueID 100.
so if i receive an item who's UniqueID that's not exist in memory structure, then need to create a new header for that UniqueID and add the items under it. And if i receive an item who's UniqueID that's already exist in memory structure, then need to add that item under that UniqueID header.
so when i need, for example if i call the header 100 then i can access the items i received for header 100 ([0,Cofee], [1,Tea], [2,Milk], ...) will be accessed. so using each UniqueID we can access the entire messages received for that ID.
if you have any idea how to do this, please help me. i'm not getting any idea. if you can provide an example then it will be great help for me. please.
thanks in advance.
2 1119
i check Dictionary properties and tried this codes. -
Public Class Form1
-
#Region "Structure"
-
Structure Order
-
-
'Data members
-
Private OrderID As Integer
-
Private OrderDetail As SortedDictionary(Of String, Integer)
-
-
Public Sub PlaceOrder(ByVal ID As Integer, ByVal Product As String, ByVal quantity As Integer)
-
OrderID = ID
-
OrderDetail.Add(Product, quantity)
-
End Sub
-
-
Public Sub UpdateOrder(ByVal Product As String, ByVal quantity As Integer)
-
OrderDetail.Add(Product, quantity)
-
End Sub
-
-
Public Sub Init()
-
Me.OrderDetail = New SortedDictionary(Of String, Integer)
-
End Sub
-
-
Public ReadOnly Property ID() As Integer
-
Get
-
Return Me.OrderID
-
End Get
-
End Property
-
-
End Structure
-
#End Region
-
-
Private placedOrder As Order = Nothing
-
Private OrderList As List(Of Order) = Nothing
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
'new instance of the order structure
-
placedOrder = New Order
-
placedOrder.Init()
-
'Place an order
-
Me.placedOrder.PlaceOrder(100, "Coffee", 200)
-
'Save the order in a list of placed order
-
Me.OrderList = New List(Of Order)
-
Me.OrderList.Add(placedOrder)
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Dim placedID As Integer = 100
-
For Each o As Order In Me.OrderList
-
'check if the id already exist in the list of orders
-
If o.ID = placedID Then 'if exist update
-
o.UpdateOrder("tea", 10)
-
Else 'create
-
placedOrder = New Order
-
placedOrder.Init()
-
placedOrder.PlaceOrder(placedID, "Coffee", 20)
-
Me.OrderList.Add(placedOrder)
-
End If
-
Next o
-
End Sub
-
-
End Class
-
but i'm using vb.net 2003 with framework 1.1. vb.net 2003 don't have SortedDictionar y at all. so i'm not able to continue right now. how can i proceed this in Vb.net 2003.
i'm adding this feature to an existing program. That existing program is in vb.net 2003 framwork 1.1. Right now i can't move forward to next version of .net.
if you have any idea please let me know and if you can provide and example then it will be great help for me. please.
Thank in advance.
Plater 7,872
Recognized Expert Expert
I would think you could accomplish this with a DataTable object.
You roughly have three columns -
UnID | ItemNumber | ItemName
-
So for example: -
UnID | ItemNumber | ItemName
-
-----------------------------------------------
-
100 | 0 | Cup
-
200 | 0 | Cup
-
100 | 1 | Spoon
-
Could be kept in your DataTable.
Doing myDataTable.Sel ect("UnID='100' ") would return a DataRow[] for all the entries that have 100 as the UnID column value.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I want my users to be able to select a report, click on a command
button on a form, which will then automatically create the report as a
pdf file and save it to the user's machine.
I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
|
by: boss_bhat |
last post by:
Hi all ,
I am beginner to C programming. I have a defined astructure like the
following, and i am using aliases for the different data types in the
structure,
typedef struct _NAME_INFO {
struct _NAME_INFO *Next;
ULONG LastId;
ULONG Id;
PVOID Value;
|
by: Alfonso Morra |
last post by:
Hi,
I am having some probs with copying memory blocks around (part of a
messaging library) and I would like some confirmation to make sure that
I'm going about things the right way.
I have some data types defined thus:
typedef enum {
ONE ,
|
by: Alfonso Morra |
last post by:
Hi,
I am writing a messaging library which will allow me to send a generic
message structure with custom "payloads".
In many cases, a message must store a non-linear data structure (i.e.
"payload") using pointers. Examples of these are binary trees, hash
tables etc. Thus, the message itself contains only a pointer to the
actual data. When the message is sent to the same processor, these
pointers point to the original locations, which...
|
by: CptDondo |
last post by:
I am working on an embedded platform which has a block of battery-backed
RAM. I need to store various types of data in this block of memory -
for example, bitmapped data for control registers, strings for logging,
and structures for data points.
I want to use one function to read data from this block and one function
to write data, for example:
sram_read(OBJECT_IDENTIFIER) would return a pointer to the appriate
object and
| |
by: Marc Miller |
last post by:
Hi all,
I have 2 dev. machines, the 1st is Win 2000 with .NET 7.0 and the 2nd is XP
Pro with .NET 2003. My Web Server is Win 2000 Server with IIS 5.0.
I can create a new project on my test server from the 1st machine, but I
receive an 'HTTP/1.1 500 Internal Server error" from my Web Server.
My userid/password are the same on all 3 machines.
|
by: jan axelson |
last post by:
My application is using RegisterDeviceNotification() to detect
attachment and removal of a USB HID-class device.
The form is receiving WM_DEVICECHANGE messages with wParam set to
DBT_DEVICEARRIVAL or DBT_DEVICEREMOVECOMPLETE.
I want to identify the device that has arrived or been removed by
examining the dbcc_name member of the DEV_BROADCAST_DEVICEINTERFACE
structure.
|
by: aki |
last post by:
Hi all,
i am writing codes for implementing network protocols.
i have written a method which is receiving a packet from network.
i have assumed that the packet i will receive will be of type char*.
i need to test my method and
for that i want to create a network buffer which will contain a
packet of format as->
example of Configuration req packet
uint8_t code;
|
by: sunil |
last post by:
Hi,
Am developing one shared library for one application.
In that .so am having one global array of structure ( two more
different structure pointers in this struct).
Once the application is launched, then I am allocating the memory on
the heap for the internal structures.
To print the log messages I am using the below mentioned global
variables and time header functions.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |