2

当我想到使用单选按钮设置“记住我”时,我正在制作一个电子邮件程序。我在想它可以保存在“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
4

2 回答 2

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()
于 2013-04-13T16:46:12.757 回答
1

首先,如果您要使用 RadioButtons,您需要拥有多个单选按钮,可能需要一个复选框。您可以使用项目用户设置在应用程序使用之间保持存储。您需要转到您的项目设置选项卡并创建设置,它应该看起来像这样:

在此处输入图像描述

你会像这样实现它

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
于 2013-04-13T17:02:34.223 回答