I have created project in VB.NET2005 for reading app.config.
Now I want the text boxes to validate input values and then store that values in child nodes Astrology,Cricket,ForeignCurrency,Jobs respectively
please help!!!!!
:'(

Dani AI

Generated

As showed, values are being loaded into text boxes on form load and asked for the code — the next step is validating those text boxes before writing the values back to your settings or config. Use simple checks (empty, numeric, regex), show feedback with an ErrorProvider or the control's Validating event, then persist only when all fields are valid. Make sure the settings you intend to change are user-scoped; application-scoped settings are read-only at runtime.

Recommended flow: 1) Decide which controls must be non-empty vs numeric vs pattern-checked. 2) Wire validation on a Save button or on each control's Validating event. 3) If validation passes, assign to your user-scoped settings and call Save() once. 4) If you need to edit app.config directly instead of user settings, use the ConfigurationManager API (requires different handling and permissions).

Example (WinForms, VB.NET):

Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
    Dim ok As Boolean = True
    Dim intVal As Integer

    errProvider.Clear()

    If String.IsNullOrWhiteSpace(txtCategory1.Text) Then
        errProvider.SetError(txtCategory1, "Value required")
        ok = False
    ElseIf Not Integer.TryParse(txtCategory1.Text, intVal) Then
        errProvider.SetError(txtCategory1, "Enter a whole number")
        ok = False
    End If

    If ok Then
        My.Settings.Category1 = txtCategory1.Text
        My.Settings.Category2 = txtCategory2.Text
        My.Settings.Save()
    End If
End Sub

Troubleshooting: if Save() has no effect, confirm the setting scope (Project -> Properties -> Settings). If you must update app.config nodes directly, use ConfigurationManager.OpenExeConfiguration and call Save, then refresh the section. For reference see the Microsoft docs on application settings and ErrorProvider: Application settings overview and ErrorProvider.

Can you please send the code you are using.

Can you please send the code you are using.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim astrology_value As String
Dim cricket_value As String
Dim foreigncurrency_value As String
Dim jobs_value As String
Dim app_path As String = System.AppDomain.CurrentDomain.BaseDirectory()

astrology_value = My.Settings.Astrology
cricket_value = My.Settings.Cricket
foreigncurrency_value = My.Settings.ForeignCurrency
jobs_value = My.Settings.Jobs

TextBox1.Text = (astrology_value)
TextBox2.Text = (cricket_value)
TextBox3.Text = (foreigncurrency_value)
TextBox4.Text = (jobs_value)
End Sub

For what?????

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.