19-03-13, 10:27 PM
حل بسيط لكنه سيقوم بحفظ البيانات ف ملف خارج البرنامج
كود :
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Dim sw As New IO.StreamWriter(My.Application.Info.DirectoryPath & "\القائمة", False, System.Text.Encoding.UTF8)
Dim s As String = ""
For i As Integer = 0 To ComboBox1.Items.Count - 1
s += ComboBox1.Items.Item(i) & vbCrLf
Next
sw.Write(s)
sw.Close()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim objReader As New System.IO.StreamReader(My.Application.Info.DirectoryPath & "\القائمة")
Dim g As String = objReader.ReadToEnd
g = Replace(g, vbCrLf, "#")
Dim rt() As String = g.Split("#")
For i As Integer = 0 To rt.Length - 1
ComboBox1.Items.Add(rt(i))
Next
Catch ex As Exception
MsgBox("الملف غير موجود")
End Try
End Sub