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-2025
 
zurück

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

VB.NET - Ein- und Umsteiger
Re: ComboBox Inhalt speichern Problem! 
Autor: viperbone
Datum: 30.08.06 13:08

Also die Funktion überprüft bei jedem Programmstart ob die Datei existiert. Wenn nicht erstellt es sie es könnte an dem liegen. Nimm folgenden Code (ich hab ihn nur geringfügig geändert.)
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
      System.EventArgs) Handles MyBase.Load
        cb_ReadData(ComboBox1, "ComboBox.txt")
    End Sub
 
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As _
      System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        cb_WriteData(ComboBox1, "ComboBox.txt")
    End Sub
 
    Public Sub cb_ReadData(ByVal cb As ComboBox, ByVal sDataFile As String, _
      Optional ByVal bAppend As Boolean = False)
        If Not bAppend Then ComboBox1.Items.Clear()
        If System.IO.File.Exists(".\" & sDataFile) = False Then
            System.IO.File.Create(".\" & sDataFile)
        Else
 
            Dim sLine As String
            Dim SR As New IO.StreamReader(".\" & sDataFile)
 
            With ComboBox1.Items
                Do Until SR.EndOfStream = True
 
                    'Linie einlesen und aufteilen
                    sLine = SR.ReadLine()
                    ' in Combobox eintragen 
                    cb.Items.Add(sLine)
                Loop
            End With
            SR.Close()
        End If
    End Sub
 
    Public Sub cb_WriteData(ByVal cb As ComboBox, ByVal sDataFile As String)
        Dim sw As New IO.StreamWriter(".\" & sDataFile, False, _
          System.Text.Encoding.Default)
        If cb.Items.Count = 0 Then
            Exit Sub
        Else
            Using sw
                For i As Integer = 0 To cb.Items.Count - 1
                    Dim text As String = cb.Items.Item(i).ToString
                    sw.Write(cb.Items.Item(i).ToString)
                    sw.WriteLine()
                Next
            End Using
            sw.Close()
        End If
    End Sub
Am besten übernimmst du ihn einmal genau so und probierst es aus. Also bei mir funktioniert er. Was du beachten solltest ist, dass du das Programm nicht mit der "Stop"-Taste beendest dann funktioniert es nicht.

fg viperbone

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
ComboBox Inhalt speichern2.998KMX Racer Woh30.08.06 09:21
Re: ComboBox Inhalt speichern1.765TiImann30.08.06 09:28
Re: ComboBox Inhalt speichern1.782KMX Racer Woh30.08.06 09:35
Re: ComboBox Inhalt speichern1.927TiImann30.08.06 10:25
Re: ComboBox Inhalt speichern1.687TiImann30.08.06 10:27
Re: ComboBox Inhalt speichern1.949viperbone30.08.06 10:32
Re: ComboBox Inhalt speichern1.698KMX Racer Woh30.08.06 10:34
Re: ComboBox Inhalt speichern1.819viperbone30.08.06 10:41
Re: ComboBox Inhalt speichern1.658KMX Racer Woh30.08.06 10:46
Re: ComboBox Inhalt speichern Problem!1.730KMX Racer Woh30.08.06 11:06
Re: ComboBox Inhalt speichern Problem!1.652viperbone30.08.06 11:25
Re: ComboBox Inhalt speichern Problem!1.656KMX Racer Woh30.08.06 11:38
Re: ComboBox Inhalt speichern Problem!2.207viperbone30.08.06 13:08
Re: ComboBox Inhalt speichern Problem!1.559KMX Racer Woh30.08.06 13:58
Re: ComboBox Inhalt speichern Problem!1.661KMX Racer Woh30.08.06 14:37
Re: ComboBox Inhalt speichern Problem!1.695viperbone30.08.06 15:49
Re: ComboBox Inhalt speichern Problem!1.781KMX Racer Woh30.08.06 16:11
Re: ComboBox Inhalt speichern Problem!1.758viperbone30.08.06 16:21
Re: ComboBox Inhalt speichern Problem!1.552KMX Racer Woh30.08.06 16:39
Re: ComboBox Inhalt speichern Problem!1.621Silver30.08.06 17:01
Re: ComboBox Inhalt speichern Problem!1.856viperbone30.08.06 18:50
Re: ComboBox Inhalt speichern Problem!1.657KMX Racer Woh31.08.06 08:20
Re: ComboBox Inhalt speichern Problem!1.633Silver31.08.06 18:53
Re: ComboBox Inhalt speichern Problem!1.653KMX Racer Woh01.09.06 08:58
Re: ComboBox Inhalt speichern Problem!1.710Silver01.09.06 15:11
Re: ComboBox Inhalt speichern Problem!1.684KMX Racer Woh01.09.06 15:51
Re: ComboBox Inhalt speichern Problem!1.628viperbone01.09.06 17:34
Re: ComboBox Inhalt speichern Problem!1.685viperbone01.09.06 17:43
Re: ComboBox Inhalt speichern Problem!1.702Silver01.09.06 18:33
Re: ComboBox Inhalt speichern Problem!1.633KMX Racer Woh04.09.06 08:37
Re: ComboBox Inhalt speichern Problem!1.655KMX Racer Woh04.09.06 08:52
Re: ComboBox Inhalt speichern Problem!1.660Chief04.09.06 08:58
Re: ComboBox Inhalt speichern Problem!1.755Silver04.09.06 11:19
Re: ComboBox Inhalt speichern1.722KMX Racer Woh30.08.06 10:30
Re: ComboBox Inhalt speichern1.714TiImann30.08.06 10:31
Re: ComboBox Inhalt speichern1.728DerLord30.08.06 21:37
Re: ComboBox Inhalt speichern1.596KMX Racer Woh31.08.06 14:53
Re: ComboBox Inhalt speichern1.693Silver31.08.06 18:54
Re: ComboBox Inhalt speichern1.731Chief01.09.06 11:42
Re: ComboBox Inhalt speichern1.806KMX Racer Woh01.09.06 12:02
Re: ComboBox Inhalt speichern- DIE LÖSUNG!1.767KMX Racer Woh04.09.06 09:25
Re: ComboBox Inhalt speichern- DIE LÖSUNG!2.272KMX Racer Woh04.09.06 09:30
Re: ComboBox Inhalt speichern-Neues kleine Problem1.718KMX Racer Woh07.09.06 08:36
Re: ComboBox Inhalt speichern-Neues kleine Problem- erledigt...1.626KMX Racer Woh07.09.06 11:42
Re: ComboBox Inhalt speichern-Neues kleine Problem- erledigt...1.695Chief19.09.06 23:40

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-2025 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