تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مساعدة في إنشاء ملف نصي
#1
السلام عليكم ورحمة الله وبركاته
في البداية أشكر الأخ 5000 عى الرد في موضوعي السابق والكود كان شغال لكنني لم أستطع توظيفه 
السطر هذا لم أستطع توظيفه رغم عدة محاولات
Dim sb As New List(Of String)
        Dim total = (From x As DataGridViewRow In DGView.Rows Select CDbl(x.Cells(4).Value)).Sum
        sb.Add("" & DGView.RowCount & "" & Today.ToLongDateString & "" & FormatNumber(total))
حيث أريد إضافة سطر  في بداية الملف النصي وجلب فقط بعض الخانات من الداتاقريد كما هو مبين في الكود الموالي
وبارك الله فيكم 

كود :
Dim Dilaoge As New SaveFileDialog
       Dilaoge.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
       Dilaoge.ShowDialog()
       Dim NomFechiers As String = Dilaoge.FileName
       Dim StreamW As StreamWriter = File.CreateText(NomFechiers)
       Dim Cellule1, Cellule2, Cellule3, Cellule4 As String
       For i As Integer = 0 To DGView.Rows.Count - 1
           Cellule2 = (DGView.Rows(i).Cells(2).Value.ToString().PadLeft(5, "0") & "")
           Cellule3 = (DGView.Rows(i).Cells(3).Value.ToString() & "")
           Cellule4 = (DGView.Rows(i).Cells(4).Value.ToString() & "")
           Cellule1 = (DGView.Rows(i).Cells(1).Value.ToString().PadLeft(27))
           StreamW.Write(Cellule2 & "" & Cellule3 & "" & GetFormatNumber(Cellule4) & "" & Cellule1)
           StreamW.WriteLine("")
       Next
       StreamW.Close()
       MessageBox.Show("تمت عملية الحفظ بنجاح")
الرد }}}
تم الشكر بواسطة:
#2
تعديل الكود

        Using Dilaoge As New SaveFileDialog
            Dilaoge.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
            If Dilaoge.ShowDialog() = Windows.Forms.DialogResult.OK Then
                Dim NomFechiers As String = Dilaoge.FileName
                Dim StreamW As StreamWriter = File.CreateText(NomFechiers)

                Dim total = (From x As DataGridViewRow In DGView.Rows Select CDbl(x.Cells(4).Value)).Sum
                StreamW.WriteLine("" & DGView.RowCount & "" & Today.ToLongDateString & "" & FormatNumber(total))

                Dim Cellule1, Cellule2, Cellule3, Cellule4 As String
                For i As Integer = 0 To DGView.Rows.Count - 1
                    Cellule2 = (DGView.Rows(i).Cells(2).Value.ToString().PadLeft(5, "0") & "")
                    Cellule3 = (DGView.Rows(i).Cells(3).Value.ToString() & "")
                    Cellule4 = (DGView.Rows(i).Cells(4).Value.ToString() & "")
                    Cellule1 = (DGView.Rows(i).Cells(1).Value.ToString().PadLeft(27))
                    StreamW.Write(Cellule2 & "" & Cellule3 & "" & GetFormatNumber(Cellule4) & "" & Cellule1)
                    StreamW.WriteLine("")
                Next
                StreamW.Close()
                MessageBox.Show("تمت عملية الحفظ بنجاح")
            End If
        End Using
الرد }}}
تم الشكر بواسطة: حريف برمجة
#3
بارك الله فيك أخي 5000 على الرد وجزاك الله خيرا أخي 
الكود شغال بارك الله فيك بقي 
في تسمية الملف على أن تكون هي قيمة التيكستبوكس1 + تيكستبوكس 2
الرد }}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: