如何保存在VB中所做的设置? [英] How to save settings made in VB?

查看:41
本文介绍了如何保存在VB中所做的设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以保存用户所做的更改,以便下次运行时它们仍然存在?我已经看到了一些关于 My.Settings 的内容,它是如何完成的?

Is there any way I can save changes made by a user , so that at the next run they would still be there? I have seen something about My.Settings , is that how it is done?

推荐答案

是的,您有多种选择,您可以创建一个文件并在启动时加载它,或者您可以使用内置的设置对象.只需转到您的 Project Property's --> settings 在那里设置您的变量,您就可以通过 My.Settings

Yes you have multiple options, you can create a file and load it on startup, or you can use the built in settings object. Just go to your Project Property's --> settings set your variable there, the you can access it through My.Settings

然后像这样加载它:

Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    Dim greeting As String = My.Settings.mySetting
End Sub

你会改变这个值并像这样保存

you would change the value and save it like this

My.Settings.mySetting = "GoodBye"
My.Settings.Save()

这篇关于如何保存在VB中所做的设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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