[VB.NET] Création de fichier .txt

Super-Fatima -  
wiederhe Messages postés 54 Statut Membre -
Bonjour,

Je réalise en ce moment un programme quelconque en vb

Je souhaiterais que lorsque l'utilisateur clique sur un bouton que le contenu des textbox affichés a l'écran s'enregistre dans un fichier de type .txt (bloc notes)

Comment puis-je procéder?
Configuration: Windows Vista
Firefox 3.0.1

2 réponses

  1. wiederhe Messages postés 54 Statut Membre 22
     
    Bonjours,

    C'est facile. Voici le projet VB.NET. Tous ces fichiers sont à mettre dans le même répertoire.

    Il faudra faire une copie dans Notepad de ce qui suis, puis les sauvegarder avec le nom indiqué en gras souligné:

    Textbox2File.vbproj

    <?xml version="1.0" encoding="utf-8"?>
    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.50727</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{FC8F7E2C-9F36-4070-8D91-798F55E552AE}</ProjectGuid>
    <OutputType>WinExe</OutputType>
    <StartupObject>Textbox2File.My.MyApplication</StartupObject>
    <RootNamespace>Textbox2File</RootNamespace>
    <AssemblyName>Textbox2File</AssemblyName>
    <MyType>WindowsForms</MyType>
    </PropertyGroup>
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <OutputPath>bin\Debug\</OutputPath>
    <DocumentationFile>Textbox2File.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
    </PropertyGroup>
    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DocumentationFile>Textbox2File.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
    </PropertyGroup>
    <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
    </ItemGroup>
    <ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="System" />
    <Import Include="System.Collections" />
    <Import Include="System.Collections.Generic" />
    <Import Include="System.Data" />
    <Import Include="System.Drawing" />
    <Import Include="System.Diagnostics" />
    <Import Include="System.Windows.Forms" />
    </ItemGroup>
    <ItemGroup>
    <Compile Include="Form1.vb">
    <SubType>Form</SubType>
    </Compile>
    <Compile Include="Form1.Designer.vb">
    <DependentUpon>Form1.vb</DependentUpon>
    <SubType>Form</SubType>
    </Compile>
    <Compile Include="My Project\AssemblyInfo.vb" />
    <Compile Include="My Project\Application.Designer.vb">
    <AutoGen>True</AutoGen>
    <DependentUpon>Application.myapp</DependentUpon>
    </Compile>
    <Compile Include="My Project\Resources.Designer.vb">
    <AutoGen>True</AutoGen>
    <DesignTime>True</DesignTime>
    <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="My Project\Settings.Designer.vb">
    <AutoGen>True</AutoGen>
    <DependentUpon>Settings.settings</DependentUpon>
    <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
    </ItemGroup>
    <ItemGroup>
    <EmbeddedResource Include="Form1.resx">
    <SubType>Designer</SubType>
    <DependentUpon>Form1.vb</DependentUpon>
    </EmbeddedResource>
    <EmbeddedResource Include="My Project\Resources.resx">
    <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
    <LastGenOutput>Resources.Designer.vb</LastGenOutput>
    <CustomToolNamespace>My.Resources</CustomToolNamespace>
    <SubType>Designer</SubType>
    </EmbeddedResource>
    </ItemGroup>
    <ItemGroup>
    <None Include="My Project\Application.myapp">
    <Generator>MyApplicationCodeGenerator</Generator>
    <LastGenOutput>Application.Designer.vb</LastGenOutput>
    </None>
    <None Include="My Project\Settings.settings">
    <Generator>SettingsSingleFileGenerator</Generator>
    <CustomToolNamespace>My</CustomToolNamespace>
    <LastGenOutput>Settings.Designer.vb</LastGenOutput>
    </None>
    </ItemGroup>
    <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
    <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    Other similar extension points exist, see Microsoft.Common.targets.
    <Target Name="BeforeBuild">
    </Target>
    <Target Name="AfterBuild">
    </Target>
    -->
    </Project>

    Form1.vb

    Public Class frmMain

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
    Me.Close()
    End Sub

    ''' <summary>
    ''' Sauvegarde le contenu d'un textbox dans un fichier nommé
    ''' Textbox.txt et le sauvegarde sous c:\
    ''' </summary>
    ''' <param name="sender" type="Object">
    ''' <para>
    ''' Objet appelant l'evenement (La feuille)
    ''' </para>
    ''' </param>
    ''' <param name="e" type="System.EventArgs">
    ''' <para>
    ''' Type d'événement
    ''' </para>
    ''' </param>
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
    Try
    'HW - Sauve le contenu du textbox
    Dim strText As String = txtText.Text.ToString
    'HW - Ouverture fichier ici
    Dim fs As New System.IO.FileStream("C:\Textbox.txt", IO.FileMode.Create, IO.FileAccess.Write)
    'HW - Objet d'écriture
    Dim swFile As New System.IO.StreamWriter(fs)
    'HW - Ecriture dans fichier
    swFile.Write(strText)

    'HW - Fermeture des objets après utilisation
    swFile.Close()
    fs.Close()

    'HW - Détruit les objects plus utilisés
    swFile = Nothing
    fs = Nothing

    MessageBox.Show("Sauvegarde réussie!", "Opération terminée", MessageBoxButtons.OK, MessageBoxIcon.Information)
    Catch ex As Exception
    'HW - Si problème, affiche erreur
    MessageBox.Show("Erreur dans la fonction btnSave: " & ex.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try

    End Sub
    End Class

    Form1.resx

    <?xml version="1.0" encoding="utf-8"?>
    <root>
    <!--
    Microsoft ResX Schema

    Version 2.0

    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.

    Example:

    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
    <comment>This is a comment</comment>
    </data>

    There are any number of "resheader" rows that contain simple
    name/value pairs.

    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.

    The mimetype is used for serialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:

    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.

    mimetype: application/x-microsoft.net.object.binary.base64
    value : The object must be serialized with
    : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
    : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.soap.base64
    value : The object must be serialized with
    : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
    : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value : The object must be serialized into a byte array
    : using a System.ComponentModel.TypeConverter
    : and then encoded with base64 encoding.
    -->
    <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
    <xsd:complexType>
    <xsd:choice maxOccurs="unbounded">
    <xsd:element name="metadata">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" />
    </xsd:sequence>
    <xsd:attribute name="name" use="required" type="xsd:string" />
    <xsd:attribute name="type" type="xsd:string" />
    <xsd:attribute name="mimetype" type="xsd:string" />
    <xsd:attribute ref="xml:space" />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="assembly">
    <xsd:complexType>
    <xsd:attribute name="alias" type="xsd:string" />
    <xsd:attribute name="name" type="xsd:string" />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="data">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
    <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
    <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
    <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
    <xsd:attribute ref="xml:space" />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="resheader">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
    </xsd:complexType>
    </xsd:element>
    </xsd:choice>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
    </resheader>
    <resheader name="version">
    <value>2.0</value>
    </resheader>
    <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    <data name="txtText.Text" xml:space="preserve">
    <value>Bonjour,

    Je realise en ce moment un programme quelconque en vb
    Je souhaiterais que lorsque l'utilisateur clique sur un bouton que le contenu des
    textbox affich a l'ecran s'enregistre dans un fichier de type .txt (bloc notes)

    Comment puis-je proceder?
    </value>
    </data>
    </root>

    Form1.Designer.vb

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    Partial Class frmMain
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
    Try
    If disposing AndAlso components IsNot Nothing Then
    components.Dispose()
    End If
    Finally
    MyBase.Dispose(disposing)
    End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
    Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain))
    Me.txtText = New System.Windows.Forms.TextBox
    Me.btnClose = New System.Windows.Forms.Button
    Me.btnSave = New System.Windows.Forms.Button
    Me.SuspendLayout()
    '
    'txtText
    '
    Me.txtText.Location = New System.Drawing.Point(12, 24)
    Me.txtText.Multiline = True
    Me.txtText.Name = "txtText"
    Me.txtText.Size = New System.Drawing.Size(268, 194)
    Me.txtText.TabIndex = 0
    Me.txtText.Text = resources.GetString("txtText.Text")
    '
    'btnClose
    '
    Me.btnClose.Location = New System.Drawing.Point(228, 226)
    Me.btnClose.Name = "btnClose"
    Me.btnClose.Size = New System.Drawing.Size(52, 35)
    Me.btnClose.TabIndex = 1
    Me.btnClose.Text = "&Close"
    Me.btnClose.UseVisualStyleBackColor = True
    '
    'btnSave
    '
    Me.btnSave.Location = New System.Drawing.Point(158, 226)
    Me.btnSave.Name = "btnSave"
    Me.btnSave.Size = New System.Drawing.Size(52, 35)
    Me.btnSave.TabIndex = 2
    Me.btnSave.Text = "&Save to File"
    Me.btnSave.UseVisualStyleBackColor = True
    '
    'frmMain
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.Controls.Add(Me.btnSave)
    Me.Controls.Add(Me.btnClose)
    Me.Controls.Add(Me.txtText)
    Me.Name = "frmMain"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "Textbox 2 File"
    Me.ResumeLayout(False)
    Me.PerformLayout()

    End Sub
    Friend WithEvents txtText As System.Windows.Forms.TextBox
    Friend WithEvents btnClose As System.Windows.Forms.Button
    Friend WithEvents btnSave As System.Windows.Forms.Button

    End Class

    Textbox2File.vbproj.user

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
    <ProjectView>ShowAllFiles</ProjectView>
    </PropertyGroup>
    </Project>

    Application.Designer.vb

    '------------------------------------------------------------------------------
    ' <auto-generated>
    ' This code was generated by a tool.
    ' Runtime Version:2.0.50727.42
    '
    ' Changes to this file may cause incorrect behavior and will be lost if
    ' the code is regenerated.
    ' </auto-generated>
    '------------------------------------------------------------------------------

    Option Strict On
    Option Explicit On

    Namespace My

    'NOTE: This file is auto-generated; do not modify it directly. To make changes,
    ' or if you encounter build errors in this file, go to the Project Designer
    ' (go to Project Properties or double-click the My Project node in
    ' Solution Explorer), and make changes on the Application tab.
    '
    Partial Friend Class MyApplication

    <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
    Public Sub New()
    MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
    Me.IsSingleInstance = false
    Me.EnableVisualStyles = true
    Me.SaveMySettingsOnExit = true
    Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
    End Sub

    <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
    Protected Overrides Sub OnCreateMainForm()
    Me.MainForm = Global.Textbox2File.frmMain
    End Sub
    End Class
    End Namespace

    Settings.Settings

    <?xml version='1.0' encoding='utf-8'?>
    <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
    <Profiles>
    <Profile Name="(Default)" />
    </Profiles>
    <Settings />
    </SettingsFile>

    AssemblyInfo.vb

    Imports System
    Imports System.Reflection
    Imports System.Runtime.InteropServices

    ' General Information about an assembly is controlled through the following
    ' set of attributes. Change these attribute values to modify the information
    ' associated with an assembly.

    ' Review the values of the assembly attributes

    <Assembly: AssemblyTitle("Textbox2File")>
    <Assembly: AssemblyDescription("")>
    <Assembly: AssemblyCompany("")>
    <Assembly: AssemblyProduct("Textbox2File")>
    <Assembly: AssemblyCopyright("Copyright © 2008")>
    <Assembly: AssemblyTrademark("")>

    <Assembly: ComVisible(False)>

    'The following GUID is for the ID of the typelib if this project is exposed to COM
    <Assembly: Guid("3934a350-c9cd-451b-a93b-84a6020bbe34")>

    ' Version information for an assembly consists of the following four values:
    '
    ' Major Version
    ' Minor Version
    ' Build Number
    ' Revision
    '
    ' You can specify all the values or you can default the Build and Revision Numbers
    ' by using the '*' as shown below:
    ' <Assembly: AssemblyVersion("1.0.*")>

    <Assembly: AssemblyVersion("1.0.0.0")>
    <Assembly: AssemblyFileVersion("1.0.0.0")>

    Ressources.Designer.vb

    '------------------------------------------------------------------------------
    ' <auto-generated>
    ' This code was generated by a tool.
    ' Runtime Version:2.0.50727.42
    '
    ' Changes to this file may cause incorrect behavior and will be lost if
    ' the code is regenerated.
    ' </auto-generated>
    '------------------------------------------------------------------------------

    Option Strict On
    Option Explicit On

    Namespace My.Resources

    'This class was auto-generated by the StronglyTypedResourceBuilder
    'class via a tool like ResGen or Visual Studio.
    'To add or remove a member, edit your .ResX file then rerun ResGen
    'with the /str option, or rebuild your VS project.
    '<summary>
    ' A strongly-typed resource class, for looking up localized strings, etc.
    '</summary>
    <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0"), _
    Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
    Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
    Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
    Friend Module Resources

    Private resourceMan As Global.System.Resources.ResourceManager

    Private resourceCulture As Global.System.Globalization.CultureInfo

    '<summary>
    ' Returns the cached ResourceManager instance used by this class.
    '</summary>
    <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
    Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
    Get
    If Object.ReferenceEquals(resourceMan, Nothing) Then
    Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Textbox2File.Resources", GetType(Resources).Assembly)
    resourceMan = temp
    End If
    Return resourceMan
    End Get
    End Property

    '<summary>
    ' Overrides the current thread's CurrentUICulture property for all
    ' resource lookups using this strongly typed resource class.
    '</summary>
    <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
    Friend Property Culture() As Global.System.Globalization.CultureInfo
    Get
    Return resourceCulture
    End Get
    Set(ByVal value As Global.System.Globalization.CultureInfo)
    resourceCulture = value
    End Set
    End Property
    End Module
    End Namespace

    Settings.Designer.vb

    '------------------------------------------------------------------------------
    ' <auto-generated>
    ' This code was generated by a tool.
    ' Runtime Version:2.0.50727.42
    '
    ' Changes to this file may cause incorrect behavior and will be lost if
    ' the code is regenerated.
    ' </auto-generated>
    '------------------------------------------------------------------------------

    Option Strict On
    Option Explicit On

    Namespace My

    <Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
    Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0"), _
    Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
    Partial Friend NotInheritable Class MySettings
    Inherits Global.System.Configuration.ApplicationSettingsBase

    Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)

    #Region "My.Settings Auto-Save Functionality"
    #If _MyType = "WindowsForms" Then
    Private Shared addedHandler As Boolean

    Private Shared addedHandlerLockObject As New Object

    <Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
    Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
    If My.Application.SaveMySettingsOnExit Then
    My.Settings.Save()
    End If
    End Sub
    #End If
    #End Region

    Public Shared ReadOnly Property [Default]() As MySettings
    Get

    #If _MyType = "WindowsForms" Then
    If Not addedHandler Then
    SyncLock addedHandlerLockObject
    If Not addedHandler Then
    AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
    addedHandler = True
    End If
    End SyncLock
    End If
    #End If
    Return defaultInstance
    End Get
    End Property
    End Class
    End Namespace

    Namespace My

    <Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
    Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
    Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
    Friend Module MySettingsProperty

    <Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
    Friend ReadOnly Property Settings() As Global.Textbox2File.My.MySettings
    Get
    Return Global.Textbox2File.My.MySettings.Default
    End Get
    End Property
    End Module
    End Namespace

    Ressources.resx

    <?xml version="1.0" encoding="utf-8"?>
    <root>
    <!--
    Microsoft ResX Schema

    Version 2.0

    The primary goals of this format is to allow a simple XML format
    that is mostly human readable. The generation and parsing of the
    various data types are done through the TypeConverter classes
    associated with the data types.

    Example:

    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
    <comment>This is a comment</comment>
    </data>

    There are any number of "resheader" rows that contain simple
    name/value pairs.

    Each data row contains a name, and value. The row also contains a
    type or mimetype. Type corresponds to a .NET class that support
    text/value conversion through the TypeConverter architecture.
    Classes that don't support this are serialized and stored with the
    mimetype set.

    The mimetype is used for serialized objects, and tells the
    ResXResourceReader how to depersist the object. This is currently not
    extensible. For a given mimetype the value must be set accordingly:

    Note - application/x-microsoft.net.object.binary.base64 is the format
    that the ResXResourceWriter will generate, however the reader can
    read any of the formats listed below.

    mimetype: application/x-microsoft.net.object.binary.base64
    value : The object must be serialized with
    : System.Serialization.Formatters.Binary.BinaryFormatter
    : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.soap.base64
    value : The object must be serialized with
    : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
    : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value : The object must be serialized into a byte array
    : using a System.ComponentModel.TypeConverter
    : and then encoded with base64 encoding.
    -->
    <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:element name="root" msdata:IsDataSet="true">
    <xsd:complexType>
    <xsd:choice maxOccurs="unbounded">
    <xsd:element name="metadata">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" />
    <xsd:attribute name="type" type="xsd:string" />
    <xsd:attribute name="mimetype" type="xsd:string" />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="assembly">
    <xsd:complexType>
    <xsd:attribute name="alias" type="xsd:string" />
    <xsd:attribute name="name" type="xsd:string" />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="data">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
    <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
    <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
    <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="resheader">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required" />
    </xsd:complexType>
    </xsd:element>
    </xsd:choice>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
    </resheader>
    <resheader name="version">
    <value>2.0</value>
    </resheader>
    <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    </resheader>
    </root>

    Application.myapp

    <?xml version="1.0" encoding="utf-16"?>
    <MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <MySubMain>true</MySubMain>
    <MainForm>frmMain</MainForm>
    <SingleInstance>false</SingleInstance>
    <ShutdownMode>0</ShutdownMode>
    <EnableVisualStyles>true</EnableVisualStyles>
    <AuthenticationMode>0</AuthenticationMode>
    <SaveMySettingsOnExit>true</SaveMySettingsOnExit>
    </MyApplicationData>

    Et Voilà

    C'est long mais les pièces jointes sont interdites alors...

    Cordialement

    Hervé
    -3