还记得当我开始我的程序时我上次做了什么吗? [英] Remember what i last did when i start my program?

查看:40
本文介绍了还记得当我开始我的程序时我上次做了什么吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喂!我有一点问题。我希望我的程序能够记住我再次启动它时最后做的事情。让我们说我在列表框中添加了一些东西。这个程序是为一个名为runescape的游戏而制作的,我想记录一些我从怪物那里得到的东西,例如,如果我添加这些东西:



1. coins

2.钢筋

3.煤炭



如果我现在退出我的程序并再次启动它,一切都是空的。我希望程序能够记住我上一次做的事情,所以下次启动它时,它看起来会完全一样。任何提示?





我试图将其保存然后再将其打开到列表框中。但问题是我有一个丢弃率所以当我添加项目时它会这样说:丢弃率:50%当我再次打开文本文件进入列表框时,它再次以100%开始,即使它是' 25%在另一个完全相同的项目上。我也有魅力下降,因为它被称为所以,如果我得到魅力下降它像这样说:



金魅力40 
绿色魅力20
深红色魅力50
蓝色魅力10



当我重新启动程序时它们也消失了我不知道我不知道如何再次将它们加载到标签中。如果我加载它们可能会从0重新开始。

[/ EDIT]

解决方案

您需要将数据绑定到您的列表框。

数据绑定Windows窗体组合框或ListBox [ ^ ]

数据绑定概述 [ ^ ]



您可以使用My.Settings对象。

My.Settings对象 [ ^ ]

管理应用程序设置 [ ^ ]


您可以将数据(如列表框行)保存在txt文件中。

请记住,您应该在Windows窗体关闭时保存数据并调用txt文件和在表单加载事件中使用它。

对于列表框中的每一行,您可以转到下一行txt文件或使用像''


''这样的字符。

Hey! I have a little problem. I want my program to remember what i last did when i start it again. Let''s say i added some things to my listbox. This program is made for a game called runescape and i want to log some things i get from monsters so for example if i add this things:

1. coins
2. steel bar
3. Coal

If i now exit my program and start it again everything is empty. I want the program to remember what i last did so next time i start it, it will look exactly the same. Any tip?

[EDIT - moved from solution]
I''ve tried to save it and then open it again into the listbox. But the problem is that i have a "Drop rate" so when i add items it says like this: drop rate: 50% and when i open the text file into the listbox again it start with 100% again even if it''s 25% on another exactly same item. I also have "charm" drop as it''s called so if i get charms in drop it says like this:

Gold charm 40
Green charm 20
Crimson charms 50
Blue charms 10


they also disappear when i restart the program and i don''t know how to load them into the labels again. And if i load them it probably would start over again from 0.
[/EDIT]

解决方案

You need to bind data to your listbox.
Data Binding a Windows Forms Combobox or ListBox[^]
Data Binding Overview[^]

You can use My.Settings object to.
My.Settings Object[^]
Managing Application Settings[^]


You can save your data(like listbox rows)in a txt file.
Remember that you should save data in close event of windows form and recall txt file and use that in form load event.
For each row in list box you can go to next line txt file or use a character like ''


''.


这篇关于还记得当我开始我的程序时我上次做了什么吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆