Register for your free account! | Forgot your password?

You last visited: Today at 19:37

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[VB.NET]

Discussion on [VB.NET] within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 15
Join Date: Jul 2012
Posts: 885
Received Thanks: 72
Exclamation [VB.NET]

Hallo Community,

ich brauche ganz dringend hilfe...

Ich habe 2 Probleme.



1. Wie kann ich eine Listbox in einer Textdatei speichern... Also wenn ich z.B. in der Listbox 123 und 1234 untereinander habe, das dieses auch untereinander in der Textbox gespeichert wird... Und wie kann ich diese dann wieder so auslesen, das das wieder in der Listbox untereinander ausgegeben wird ?

2. Wie kann ich es schaffen, das wenn ich in der einen Textbox "123" reinschreibe, das in der anderen Textbox "ABC" ausgegeben wird... Ich weiß das es mit replace gemacht wird, doch bisher wurde nur der letzte Buchstabe ersetzt..



Vielen Dank schonmal für die Hilfe





Freundliche Grüße
Turbo-Fire
TF-ART is offline  
Old 11/10/2012, 17:23   #2
 
Kraizy​'s Avatar
 
elite*gold: 0
The Black Market: 471/0/0
Join Date: Apr 2010
Posts: 9,696
Received Thanks: 1,811
Zu beiden: Schleifen nutzen. Textdatei speichern/laden mit StreamWriter/Reader.
Kraizy​ is offline  
Old 11/10/2012, 17:38   #3
 
elite*gold: 35
Join Date: Jun 2012
Posts: 1,126
Received Thanks: 43
ich kann es dir leider nur in C# sagen hoffe es hilf abe trotzdem weiter
C# und VB.Net sind ja in einige sachen gelich

Code:
using (SaveFileDialog sF = new SaveFileDialog())
            {
                sF.Filter = "Text Files|*.txt|All Files|*.*";
                if (sF.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    int proxyCount = checkedList.Items.Count;

                    foreach (String s in checkedList.Items)
                    {
                        try
                        {
                            File.WriteAllLines(sF.FileName, checkedList.Items.Cast<string>());
                        }
                        catch (Exception exc)
                        {
                            MessageBox.Show(exc.ToString());
                        }
                    }
                }
            }
master_oli is offline  
Old 11/10/2012, 19:11   #4
 
'Heaven.'s Avatar
 
elite*gold: 1
The Black Market: 331/0/0
Join Date: Jun 2012
Posts: 5,819
Received Thanks: 3,200
Zum Speichern:
Code:
    Public Function SaveListbox()
        Try
            Dim sav As New SaveFileDialog
            sav.Filter = "Textdatei|*.txt"

            If sav.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim text As String = ""
                For Each Item As String In ListBox1.Items
                    text &= vbCrLf & Item
                Next
                IO.File.WriteAllText(sav.FileName, text)
                Return True
                GoTo 1
            End If
        Catch ex As Exception
            Return False
        End Try
        Return False
1:
    End Function
Zum Auslesen:

Code:
 Private Sub listboxload(ByVal Path As String)
        Try
            For Each Text As String In IO.File.ReadAllText(Path).Split(Chr(13) & Chr(10))
                ListBox1.Items.Add(Text)
            Next
        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString(), "Error")
        End Try
    End Sub
'Heaven. is offline  
Reply




All times are GMT +1. The time now is 19:37.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.