存储用户输入(Visual Basic)(Storing user input (Visual Basic))

编程入门 行业动态 更新时间:2024-10-27 04:36:41
存储用户输入(Visual Basic)(Storing user input (Visual Basic))

我正在创建一个应用程序,它将接受大量用户输入,存储数据一段时间,并最终(在一天结束时)将其导出到excel文件。

一个例子可能是用户输入他们一整天所做的事情。 早餐/在家/ 10分钟。 然后他们将输入Coding / At Work / 8小时。 然后在通勤/地铁/ 15分钟。 等等。

我可以处理用户界面,并导出到excel。

我只是想知道什么是存储数据的最佳方式,并在程序运行时将其显示回用户。 我习惯于在Excel本身使用宏,在那里我可以简单地将每行数据存储在excel电子表格本身的另一行中。

我仍然喜欢类似电子表格的显示,这样用户就可以进入每个数据点并纠正任何错误。 但我将其作为使用visual basic的独立应用程序。 幸运的是,我认为ListView或DataGridView工具可以让我这样做。

目前我正在考虑使用的方法只是将所有用户输入存储在一个数组中。 但是每次用户创建新条目时,我都必须对数组进行ReDim并增加其大小。

但是,我已经看到了这个问题,那就是数组必须不断地存储在活动内存中。 如果用户的计算机崩溃,那么所有数据都将丢失。

我在这里真的是一个新手,所以我可以使用一些关于如何存储这样的用户输入的指导。

I'm creating an application that will take a number of user inputs, store the data for a while, and eventually (at the end of the day) export it to an excel file.

An example might be that a user would input what they did throughout the day. Breakfast/At Home/for 10 minutes. Then later on they would input Coding/At Work/8 hours. Then later on Commuting/Subway/15 minutes. Etc.

I can handle the user interface, and the exporting to excel.

I'm just wondering what might be the best way to store that data and display it back to the user while the program is running. I'm used to working with macros in Excel itself, where I could simply store each row of data in another row on the excel spreadsheet itself.

I would still like a spreadsheet-like display, so that the user can go in to each data point and correct any mistakes. But I am making this as a standalone application using visual basic. Fortunately, I think the ListView or DataGridView tools will let me do this.

At the moment the method I'm thinking of using is simply to store all the user inputs in an array. But I would have to ReDim the array and increase its size each time the user created a new entry.

I can already see a problem with this, however, and that is that an array would have to be constantly stored in active memory. If the user's computer were to crash then all the data would be lost for good.

I'm really a rookie here, so I could use some guidance on how to store a bunch of user inputs like this.

最满意答案

您可以使用数据库文件。 将存储数据的本地Sql Server Compact Editon数据库(单个文件)。 您可以使用Entity Framework与此数据库进行交互。

如果您想使用Code First(从您的代码生成数据库),请使用: https : //www.codeproject.com/Articles/680116/Code-First-with-SQL-CE

如果要使用Database First(从数据库生成实体),请使用以下命令: http : //erikej.blogspot.com/2013/11/entity-framework-6-sql-server-compact-4_25.html

您也可以使用SQLite或其他类型的数据库文件,但我喜欢SQL Server CE

You can use a database file. A local Sql Server Compact Editon database (a single file) that will store your data. You can use Entity Framework to interact with this database.

If you want to use Code First (generate your database from your code) use this: https://www.codeproject.com/Articles/680116/Code-First-with-SQL-CE

If you want to use Database First (generate your entities from your database) use this: http://erikej.blogspot.com/2013/11/entity-framework-6-sql-server-compact-4_25.html

You can also use SQLite or other kind database file, but i like SQL Server CE

更多推荐

本文发布于:2023-08-05 22:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1440104.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户   Visual   Basic   input   user

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!