保存记住我按钮? (VB.net)

时间:2013-04-13 16:22:04

标签: vb.net visual-studio outlook outlook-addin

当我使用单选按钮发现“记住我”设置的想法时,我正在制作一个电子邮件程序。我认为它可以保存在“textbox4”,“textbox5”和“textbox6”中输入的内容。这有可能吗?

编辑:

我的朋友告诉我这种方法可行,但似乎不是:

Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
    TextBox4.Text = (TextBox4.Text)
    TextBox5.Text = (TextBox5.Text)
    TextBox6.Text = (TextBox6.Text)
End Sub

2 个答案:

答案 0 :(得分:1)

废弃你被告知的事情并试试这个

使用字符串变量来保存此会话的数据,就像这样

    Dim box1 as string
    Dim box2 as string
    Dim box3 as string

Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged

    Call SaveInput() 
    'OR
    Call SaveInputToFile()
    ' OR BOTH

End Sub

Public Sub Saveinput()

   box1 = TextBox4.Text
   box2 = TextBox5.Text
   box3 = TextBox6.Text 

End Sub

如果要将其保存到文件中以便在其他会话中使用

Public Sub SaveinputtoFile()


  Dim writer As System.IO.StreamWriter = New System.IO.StreamWriter("FilePath",  False)

    writer.write(TextBox4.Text)
    writer.writeline()
    writer.write(TextBox5.Text)
    writer.writeline()
    writer.write(TextBox6.Text)
    writer.writeline()
    writer.dispose()

答案 1 :(得分:1)

首先,如果你要使用RadioButtons,你将需要不止一个,可能需要一个复选框。您可以使用“项目用户设置”在应用程序使用之间保留存储。您需要转到“项目设置”选项卡并创建“设置”,它应如下所示:

enter image description here

你会实现类似这样的东西

Public Class Form1

   Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged

        My.MySettings.Default.TextBox4 = TextBox4.Text
        My.MySettings.Default.TextBox5 = TextBox5.Text
        My.MySettings.Default.TextBox6 = TextBox6.Text
        My.MySettings.Default.Save()

    End Sub

    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        TextBox4.Text = My.MySettings.Default.TextBox4
        TextBox5.Text = My.MySettings.Default.TextBox5
        TextBox6.Text = My.MySettings.Default.TextBox6
    End Sub
End Class