vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Mails senden, abrufen und decodieren - ganz easy ;-)  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2024
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Ein- und Umsteiger
Quellcode von XML-Output vereinfachen / kürzen 
Autor: Olli_
Datum: 24.08.09 11:17

Hiho,
ich arbeite derzeit mit einer Funktion, die allerdings etwas umfassend ist. Ich meine man könnte sie kürzen.
 
Imports System.Environment
Imports System.Xml.Serialization
Imports System.IO
 
' Funktion XML-Output
Public Class toxml
 
    Public Sub Save(ByVal costestimation As costestimation, ByVal fileName As _
      String)
        Dim xs As New XmlSerializer(GetType(costestimation))
        Dim configFile As Stream = File.Open(fileName, FileMode.Create, _
          FileAccess.Write)
 
        xs.Serialize(configFile, costestimation)
        configFile.Close()
 
    End Sub
 
    Public Function Load(ByVal fileName As String) As costestimation
        Dim xs As New XmlSerializer(GetType(costestimation))
        Dim configFile As Stream = File.Open(fileName, FileMode.Open, _
          FileAccess.Read)
        Dim costestimation As costestimation = xs.Deserialize(configFile)
 
        configFile.Close()
        Return costestimation
 
    End Function
 
 
' Kürzbarer Teil (?) darunter
Public Class costestimation
 
    Private _textbox1 As String = ""
    Private _textbox2 As String = ""
    Private _textbox3 As String = ""
    Private _textbox4 As String = ""
    Private _textbox5 As String = ""
    Private _textbox6 As String = ""
    Private _textbox7 As String = ""
    Private _textbox8 As String = ""
    Private _textbox9 As String = ""
    Private _textbox10 As String = ""
    Private _textbox11 As String = ""
 
    Public Property textbox1() As String
        Get
            Return _textbox1
        End Get
 
        Set(ByVal Value As String)
            _textbox1 = Value
        End Set
    End Property
 
    Public Property textbox2() As String
        Get
            Return _textbox2
        End Get
 
        Set(ByVal Value As String)
            _textbox2 = Value
        End Set
    End Property
 
    Public Property textbox3() As String
        Get
            Return _textbox3
        End Get
 
        Set(ByVal Value As String)
            _textbox3 = Value
        End Set
    End Property
 
    Public Property textbox4() As String
        Get
            Return _textbox4
        End Get
 
        Set(ByVal Value As String)
            _textbox4 = Value
        End Set
    End Property
 
    Public Property textbox5() As String
        Get
            Return _textbox5
        End Get
 
        Set(ByVal Value As String)
            _textbox5 = Value
        End Set
    End Property
 
    Public Property textbox6() As String
        Get
            Return _textbox6
        End Get
 
        Set(ByVal Value As String)
            _textbox6 = Value
        End Set
    End Property
 
    Public Property textbox7() As String
        Get
            Return _textbox7
        End Get
 
        Set(ByVal Value As String)
            _textbox7 = Value
        End Set
    End Property
 
    Public Property textbox8() As String
        Get
            Return _textbox8
        End Get
 
        Set(ByVal Value As String)
            _textbox8 = Value
        End Set
    End Property
 
    Public Property textbox9() As String
        Get
            Return _textbox9
        End Get
 
        Set(ByVal Value As String)
            _textbox9 = Value
        End Set
    End Property
 
    Public Property textbox10() As String
        Get
            Return _textbox10
        End Get
 
        Set(ByVal Value As String)
            _textbox10 = Value
        End Set
    End Property
 
    Public Property textbox11() As String
        Get
            Return _textbox11
        End Get
 
        Set(ByVal Value As String)
            _textbox11 = Value
        End Set
    End Property
 
End Class
Aufruf:
 
    Private Sub btn_Save_Click(ByVal sender As System.Object, ByVal e As _
      System.EventArgs) Handles btn_Save.Click
        Dim costestimation As New costestimation
        Dim toxml As New toxml
        Dim filename = "wpd_standard_metrics.xml"
 
        costestimation.textbox1 = TextBox14.Text
        costestimation.textbox2 = TextBox15.Text
        costestimation.textbox3 = TextBox16.Text
        costestimation.textbox4 = TextBox17.Text
        costestimation.textbox5 = TextBox18.Text
        costestimation.textbox6 = TextBox19.Text
        costestimation.textbox7 = TextBox20.Text
        costestimation.textbox8 = TextBox21.Text
        costestimation.textbox9 = TextBox22.Text
        costestimation.textbox10 = TextBox23.Text
        costestimation.textbox11 = TextBox24.Text
 
        toxml.Save(costestimation, filename)
    End Sub
Ich habe den evtl. zu langen Teil mit einem Kommentar markiert. Kann man das vereinfachen?

Danke und Gruß,
Olli
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Quellcode von XML-Output vereinfachen / kürzen1.416Olli_24.08.09 11:17

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2024 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel