By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

Serialization of arrays (Recipe program)

P: 6
Hello, I am looking for solution that will help me to store an data in arrays, so that next time when i open program i could open it and it will be in the save form.
Serialization is the thing that I would need to do, but I really find hard to understand it, where does these variables go and how to use this process to convert data in XML or binary. Any help would be appreciated. Thanks.

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim recipename As String
  3.     Dim recipeserves As Integer
  4.  
  5.     Dim ingredients(25) As String
  6.     Dim index As Integer
  7.     Dim ingredientindex As Integer
  8.     Dim ingredientquantity(25) As Integer
  9.     Dim ingredientunit(25) As String
  10.  
  11.  
  12.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  13.         recipename = InputBox("Please enter your recipe name.")
  14.         recipeserves = InputBox("Please enter serves number for this recipe.")
  15.         index = InputBox("Please enter ingredients number.")
  16.  
  17.         txtnames.Text = recipename
  18.         txtserves.Text = recipeserves
  19.  
  20.  
  21.  
  22.         'For recipe ingredients
  23.         For Me.ingredientindex = 1 To index
  24.             ingredients(ingredientindex) = InputBox("Please enter ingredient name.")
  25.             ingredientquantity(ingredientindex) = InputBox("Please enter ingredient quantity for the following ingredient.")
  26.             ingredientunit(ingredientindex) = InputBox("Please enter ingredient unit for the following ingredient")
  27.         Next
  28.         For Me.ingredientindex = 1 To index
  29.             lstbox.Items.Add(ingredients(ingredientindex))
  30.             lstbox1.Items.Add(ingredientquantity(ingredientindex))
  31.             lstbox2.Items.Add(ingredientunit(ingredientindex))
  32.         Next
  33.  
  34.  
  35.  
  36.     End Sub
  37.  
  38.     ' Dim filename As String
  39.  
  40.     ' Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
  41.  
  42.     'Saving to text file
  43.     '    filename = InputBox("Please enter a filename")
  44.     ' FileOpen(1, filename, OpenMode.Output)
  45.     ' For Me.ingredientindex = 1 To index
  46.     '      PrintLine(1, ingredients(ingredientindex) & " " & ingredientquantity(ingredientindex) & " " & ingredientunit(ingredientindex))
  47.     '  Next
  48.     '  FileClose(1)
  49.  
  50.     ' End Sub
  51.  
  52. End Class
  53.  
Feb 16 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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