473,394 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Create memory structure for receiving messages

115 100+
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,Coffee"
for example 2: "200,1,plate"

for the first time while i run the program for example i receive a message like "100,0,Coffee". 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.
Mar 4 '08 #1
2 1100
remya1000
115 100+
i check Dictionary properties and tried this codes.

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2. #Region "Structure"
  3.     Structure Order
  4.  
  5.         'Data members        
  6.         Private OrderID As Integer
  7.         Private OrderDetail As SortedDictionary(Of String, Integer)
  8.  
  9.         Public Sub PlaceOrder(ByVal ID As Integer, ByVal Product As String, ByVal quantity As Integer)
  10.             OrderID = ID
  11.             OrderDetail.Add(Product, quantity)
  12.         End Sub
  13.  
  14.         Public Sub UpdateOrder(ByVal Product As String, ByVal quantity As Integer)
  15.             OrderDetail.Add(Product, quantity)
  16.         End Sub
  17.  
  18.         Public Sub Init()
  19.             Me.OrderDetail = New SortedDictionary(Of String, Integer)
  20.         End Sub
  21.  
  22.         Public ReadOnly Property ID() As Integer
  23.             Get
  24.                 Return Me.OrderID
  25.             End Get
  26.         End Property
  27.  
  28.     End Structure
  29. #End Region
  30.  
  31.     Private placedOrder As Order = Nothing
  32.     Private OrderList As List(Of Order) = Nothing
  33.  
  34.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  35.         'new instance of the order structure        
  36.         placedOrder = New Order
  37.         placedOrder.Init()
  38.         'Place an order        
  39.         Me.placedOrder.PlaceOrder(100, "Coffee", 200)
  40.         'Save the order in a list of placed order        
  41.         Me.OrderList = New List(Of Order)
  42.         Me.OrderList.Add(placedOrder)
  43.     End Sub
  44.  
  45.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  46.         Dim placedID As Integer = 100
  47.         For Each o As Order In Me.OrderList
  48.             'check if the id already exist in the list of orders            
  49.             If o.ID = placedID Then 'if exist update                
  50.                 o.UpdateOrder("tea", 10)
  51.             Else 'create                
  52.                 placedOrder = New Order
  53.                 placedOrder.Init()
  54.                 placedOrder.PlaceOrder(placedID, "Coffee", 20)
  55.                 Me.OrderList.Add(placedOrder)
  56.             End If
  57.         Next o
  58.     End Sub
  59.  
  60. End Class
  61.  
but i'm using vb.net 2003 with framework 1.1. vb.net 2003 don't have SortedDictionary 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.
Mar 4 '08 #2
Plater
7,872 Expert 4TB
I would think you could accomplish this with a DataTable object.
You roughly have three columns
Expand|Select|Wrap|Line Numbers
  1. UnID | ItemNumber | ItemName
  2.  
So for example:
Expand|Select|Wrap|Line Numbers
  1. UnID | ItemNumber | ItemName
  2. -----------------------------------------------
  3. 100   |      0           |  Cup
  4. 200   |      0           |  Cup
  5. 100   |      1           |  Spoon
  6.  
Could be kept in your DataTable.

Doing myDataTable.Select("UnID='100'") would return a DataRow[] for all the entries that have 100 as the UnID column value.
Mar 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
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...
7
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 {...
9
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...
5
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....
9
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,...
9
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...
5
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...
4
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.