Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     Private Sub DATABASE_Save()
  2.         Dim sb As New StringBuilder
  3.         For Each item As Alimento In Alimentos
  4.             sb.AppendLine($"{item.Categoria}|{item.Alimento}|{item.Calorias}|{item.Proteinas}|{item.Hidratos}|{item.Lipidos}|{item.Gorduras}|{item.Quantidade}")
  5.         Next
  6.         System.IO.File.WriteAllText(PATH_DATABASE, sb.ToString)
  7.     End Sub
  8.  
  9.     Private Sub DATABASE_Open()
  10.         Dim sb As New StringBuilder
  11.         Dim lines() As String = IO.File.ReadAllLines(PATH_DATABASE)
  12.         For Each line In lines
  13.             Alimentos.Add(New Alimento("1", "2", "3", "4", "5", "6", "7", "8"))
  14.             'Basically, first it checks for how many lines the text document has and then adds each Alimento accordingly to how many lines there are. Where I'm stuck: numbers (1-8) should contain each item inside each line. Hope that makes sense?
  15.        Next
  16.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement