473,837 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create memory structure for receiving messages

115 New Member
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.
Mar 4 '08 #1
2 1119
remya1000
115 New Member
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 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.
Mar 4 '08 #2
Plater
7,872 Recognized Expert Expert
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.Sel ect("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
8878
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
7
2105
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;
9
1959
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 ,
5
4809
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...
9
2445
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
9
2312
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.
5
7745
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.
4
3962
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;
1
2596
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.
0
9846
marktang
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...
1
10638
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,...
0
10280
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 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...
0
9418
agi2029
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...
0
7009
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();...
0
5859
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4480
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
2
4054
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3128
bsmnconsultancy
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...

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.