تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
قراءة ملف نصي الى DataGridView
#1
السلام عليكم ورحمة الله وبركاته

كنت استخدمة في قراءة ملف نصي في vb 6
القراءة الى اداة MSFlexCrid

الكود
كود :
Dim findfile As Boolean
Dim i
CommonDialog1.DialogTitle = " حدد أسم الرساله"
CommonDialog1.FileName = ""
txtfile = ""
CommonDialog1.Filter = "رسائل فقط|*.txt"
CommonDialog1.ShowOpen
txtfile = CommonDialog1.FileName
If (txtfile <> "") And (txtfile <> " ") Then
  
  Open txtfile For Input As #1 ' Open file.
  no_of_line = 0
  Do While Not EOF(1) ' Loop until end of file.
    no_of_line = no_of_line + 1
    txt(no_of_line) = ""
    Line Input #1, txt(no_of_line)
  Loop
  Close #1    ' Close file.
  Label1 = CommonDialog1.FileName
  txt_to_char
  kind = 1
  find_nm
  char_in_mat
  End If
End Sub

Public Sub char_in_mat()
Dim i, j, k, l As Integer
'----------  تحديد n  : أعمدة  & M : صفوف ----
'-----  من خلال nochars kind 1 &  2 &  3  & 5
mfg1.Cols = n + 1
m = m * 2
mfg1.Rows = m + 1
mfg1.Clear
Dim s$
s = "   "
For l = 1 To n:    s = s + Space(kind) + " |" + Space(kind * 2): Next
s = s + "    "
mfg1.FormatString = s
For l = 1 To m
      If (l Mod 2) <> 0 Then mfg1.TextMatrix(l, 0) = Str(l)
Next

For l = 1 To n:   mfg1.TextMatrix(0, l) = Str(l): Next
'-------------------------------------------------
j = 0
For i = 1 To m Step 2
For k = 1 To n
  For l = 1 To kind
   j = j + 1
   mfg1.TextMatrix(i, k) = mfg1.TextMatrix(i, k) + char(j) + " "
   If j >= nochar Then GoTo out
  Next
Next
Next
out:
lAb_nochar = Int(j / kind)
mfg1.Visible = True

وهذا المديول المستخدم معه
كود :
Option Explicit
Public char(20000) As String
Public txt(300) As String
Public n, m, kind As Integer
Public no_of_line, nochars, nochar As Integer
Public axis(5, 100) As String

Public Sub find_nm()
Dim i As Byte
nochar = nochars
' nochar = nochar - (nochar Mod kind)
Select Case kind
   Case 1
       n = 50: i = 50
   Case 2
       n = 25: i = 50
   Case 3
      n = 17: i = 51
   Case 4
      n = 12: i = 48
   Case 5
      n = 10: i = 50
   Case 6
      n = 8: i = 48
End Select
If (nochar Mod i) <> 0 Then
     m = Int(nochar / i) + 1
Else
     m = Int(nochar / i)
End If

End Sub

Public Sub txt_to_char()
Dim i, j
nochars = 0
' I : عدد الاسطر من 5الي نهاية الرسالة
' j : من 1 الي طول الاسترنغ
For i = 5 To no_of_line
  For j = 1 To Len(txt(i))
    If Mid(txt(i), j, 1) <> " " Then
      nochars = nochars + 1
      char(nochars) = Mid(txt(i), j, 1)
    End If
  Next
Next
End Sub

المطلوب كيف استخدم نفس الفكرة مع vb.net 2008
ومع الاداة DataGridView
مع العلم ان القراءة تكون سطر وترك ستطر
وتبداء القراءة من الملف النصي من بعد السطر الخامس
مع الغاء المسافات بين الكلمات
الرد }}}
تم الشكر بواسطة:
#2
هذا المثال بلغة VB 6


الملفات المرفقة
.rar   ReadFiles.rar (الحجم : 3.35 ك ب / التحميلات : 52)
الرد }}}
تم الشكر بواسطة:



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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم