Okay so im writing a program for my vegetarian girlfriend that does two things from the main menu. 1: add foods with 开发者_开发百科attributes like name, iron content, protein, sodium etc. 2: use the foods that have already been stored and use them to make a balanced meal. What im having trouble with is, how do i save the attributes when storing the foods ? i have knowledge with c++ so i understand how classes work and was wondering if there is something similar in Visual Basic. I would also like to know how to save the foods so that they can be used again when the program is closed and then reopened. Thanks in advance. I am VB noob but i do have some c++ knowledge.
Well, you'll need the data to be persistant, so that, when she closes and reopens the application, previosly entered data is still there.
The best and simplest approach to do that, IMHO, is to use a database, since, databases are great at just that - storing data. However, that will add some complexity to your application. I would recomend to take a look at SQLite, using a .net driver. That will give you all the benifits of a database, and will take away at least some of the complexity.
Yes, VB.net have advance OOP capability. Just instantiate the class and play with it.
class Food public dim food_name as string public sub save() 'wirte code to save the class data end sub end class 'Use it as Dim food as Food food =new Food() food.save()
To store the data u can use Database like Acess/Sql server or simply u can store them in plain text and xml. in my suggestion use XML to store the data
精彩评论