منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : اريد كود الكتابة في ملف txt في مكان محدد
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
عفوا اخواني 
اريد كود الكتابة في مكان محدد في الملف txt
وليكن في اخر الملف
وشكرا للجميع
(10-06-21, 04:23 AM)العواجي كتب : [ -> ]عفوا اخواني 
اريد كود الكتابة في مكان محدد في الملف txt
وليكن في اخر الملف
وشكرا للجميع

PHP كود :
Imports System.IO
Public Class Form1
    Dim txtpath 
As String IO.Path.GetDirectoryName(Application.ExecutablePath) & "\t.txt"
 
   Private Sub gd()
 
       ListBox1.Items.Clear()
 
       For Each h As String In My.Computer.FileSystem.ReadAllText(txtpath).Split(vbNewLine)
 
           If Trim(h.Trim).Trim <> "" Then
                ListBox1
.Items.Add(h.ToString.Trim)
 
           End If
 
       Next
    End Sub
    Private Sub Form1_Load
(sender As ObjectAs EventArgsHandles MyBase.Load
        If IO
.File.Exists(txtpath) = False Then
            IO
.File.CreateText(txtpath).Close()
 
       End If
 
       gd()
 
   End Sub
    Private Sub Button1_Click
(sender As ObjectAs EventArgsHandles Button1.Click
        If TextBox1
.Text.Trim <> "" Then
            Dim sr 
As StreamWriter
            sr 
IO.File.AppendText(txtpath)
 
           sr.WriteLine(TextBox1.Text)
 
           sr.Close()
 
       End If
 
       TextBox1.Clear()
 
       TextBox1.Focus()
 
       TextBox1.Select()
 
       gd()
 
   End Sub
End 
Class