الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف ممكن اتعامل مع الفايل؟

بدأه تـــالا في 1 يناير 2009 · 17 رد · 1,458 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكــم ورحمـة الله وبركاتــه

ان شالله يكون الجميع بالف خير

انا عندي مشروع بالفيجوال قائم بشكل اساسي عالفايلات وكيف اتعامل معها

انشاء _ فتح _ اغلاق _ اضافه _ تعديل _ حذف

وانا للاسف تنحت بشغلتين

الاولى: كيف اقدر اعدل على فايل موجود عندي

يعني مثلا فايل فيه اسماء الطلاب وارقامهم الجامعيه وبيانات اخرى .. انا بفتح الملف للقراءه والكتابه

وراح اقرا الملف الين القى اسم الطالب الي ابغاه واعدل رقمه الجامعي

كيف اقدر اسويها؟

الثانيه: كيف اقدر اقرا اسماء الطلاب واختار طالب معين واحذفه؟

ياليت تجابوني :huh:

#2

مرحباً .

سؤال : ملفات بمعنى ( ملفات نصية أو رقمية ) أو ملفات داخل قاعدة بيانات ؟

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#3

وأنا كمان أبغى مــــــــساعدة في الفايل :excl:

أنا مشروعي إنه فايل فيه عدة أسئلة , كيف أختار سؤال معين وأمسحه .... يعني كيف أعرف مثلا إذا اخترت السؤال الرابع إني أحذف الرابع وبعدين أسوي شفت يعني أحذف الفراغ في الفايل

وكمان كيف أعدل على سؤال معين بعد ماأظهرته في الريتش تكست وأسويله سايف

والفايلات من نوع txt

والله يوفقك الي يرد عليه ويحققله مطلبه

>>>>>>ياليت قبل الساعة وحده اليوم :wub:

تحياتي للجميع :salam:

#4

مو فاهمه صراحه ايش قصدك

بس الملف نوعه txt

ويحتوي على اسماء طلاب وارقامهم وكذا شغلات

شاكره لك تعاونك

تم تعديل هذه المشاركة بواسطة تـــالا في 1 يناير 2009 في 20:14

#5

حسنأً أفهم من هذا الكلام أنك تريدين التعامل مع ملفات نصية, صحيح ؟

الذي قصدته بسؤالي : هل تريدين ( الكتابة, القراءة, التعديل ) From A Text File Or A Binary File أو From A DataBase ؟

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#6

من تكست فايل

ابغى اعدل واحذف

يعني لو عندي تكست فايل فيه اسماء طلاب وارقامهم الجامعيه

وطلب اليوزر يعدل بيانات طالب معين

راح اضطر افتح الفايل واقرا لحد ماالقى اسم الطالب اللي دخله

بعدين احط التعديل اللي يبغاه

او مثلا طلب مني اليوزر احذف بيانات طالب معين

راح اقرا الاسما لحد مالقا اسم الطالب واحذفه من الفايل

كيف ممكن اسويها؟ :huh:

#7

جرب هذا المثال :

CSV Files

 

Imports [color= #990000;]System[color= #339933;].IO

[color= #000000; font-weight: bold;]Public [color= #000000; font-weight: bold;]Class Form1

    [color= #000000; font-weight: bold;]Private DataGridView1 [color= #b1b100;]As [color= #000000; font-weight: bold;]New DataGridView

    [color= #000000; font-weight: bold;]Private WithEvents Button1[color= #339933;], Button2 [color= #b1b100;]As [color= #000000; font-weight: bold;]New Button

    [color= #000000; font-weight: bold;]Private Sub Form1_Load[color= #009900;](ByVal Sender [color= #b1b100;]As [color= #990000;]System[color= #339933;].Object[color= #339933;], [color= #990000;]_

    ByVal E [color= #b1b100;]As [color= #990000;]System[color= #339933;].EventArgs[color= #009900;]) Handles MyBase[color= #339933;].Load

        DataGridView1[color= #339933;].Columns[color= #339933;].Add[color= #009900;]([color= #0000ff;]"CName"[color= #339933;], [color= #0000ff;]"Name"[color= #009900;])

        DataGridView1[color= #339933;].Columns[color= #339933;].Add[color= #009900;]([color= #0000ff;]"CMiddleN"[color= #339933;], [color= #0000ff;]"Middle Name"[color= #009900;])

        DataGridView1[color= #339933;].Columns[color= #339933;].Add[color= #009900;]([color= #0000ff;]"CLastN"[color= #339933;], [color= #0000ff;]"Last Name"[color= #009900;])

        DataGridView1[color= #339933;].Columns[color= #339933;].Add[color= #009900;]([color= #0000ff;]"CSTID"[color= #339933;], [color= #0000ff;]"Student ID"[color= #009900;])

        DataGridView1[color= #339933;].Columns[color= #339933;].Add[color= #009900;]([color= #0000ff;]"CE-mail"[color= #339933;], [color= #0000ff;]"E-mail Address"[color= #009900;])

        [color= #b1b100;]For I [color= #b1b100;]As Integer [color= #339933;]= [color= #cc66cc;]0 To [color= #cc66cc;]19

            Dim NRow [color= #b1b100;]As String[color= #009900;]([color= #009900;]) [color= #339933;]= [color= #009900;]{[color= #0000ff;]"Empty"[color= #339933;], [color= #0000ff;]"Empty"[color= #339933;], [color= #0000ff;]"Empty"[color= #339933;], [color= #990000;]_

            CInt[color= #009900;](Rnd[color= #009900;]([color= #009900;]) [color= #339933;]* I[color= #009900;])[color= #339933;], [color= #0000ff;]"Empty@Hotmail.com"[color= #009900;]}

            DataGridView1[color= #339933;].Rows[color= #339933;].Add[color= #009900;](NRow[color= #009900;])

        [color= #990000;]Next

        Button1[color= #339933;].Text [color= #339933;]= [color= #0000ff;]"فتح"

        Button1[color= #339933;].Size [color= #339933;]= [color= #000000; font-weight: bold;]New Size[color= #009900;]([color= #cc66cc;]50[color= #339933;], [color= #cc66cc;]22[color= #009900;])

        Button2[color= #339933;].Size [color= #339933;]= Button1[color= #339933;].Size

        Button2[color= #339933;].Text [color= #339933;]= [color= #0000ff;]"حفظ"

        Button1[color= #339933;].Location [color= #339933;]= [color= #000000; font-weight: bold;]New Point[color= #009900;](CInt[color= #009900;](Width [color= #339933;]- [color= #009900;](Button1[color= #339933;].Width [color= #339933;]* [color= #cc66cc;]3[color= #009900;])[color= #009900;])[color= #339933;], [color= #990000;]_

        CInt[color= #009900;](Height [color= #339933;]- [color= #009900;](Button1[color= #339933;].Height [color= #339933;]+ [color= #cc66cc;]40[color= #009900;])[color= #009900;])[color= #009900;])

        Button2[color= #339933;].Location [color= #339933;]= [color= #000000; font-weight: bold;]New Point[color= #009900;](CInt[color= #009900;](Button1[color= #339933;].Left [color= #339933;]+ Button1[color= #339933;].Width[color= #009900;])[color= #339933;], Button1[color= #339933;].Top[color= #009900;])

        Button1[color= #339933;].Anchor [color= #339933;]= [color= #cc66cc;]10

        Button2[color= #339933;].Anchor [color= #339933;]= Button1[color= #339933;].Anchor

        Controls[color= #339933;].Add[color= #009900;](Button1[color= #009900;]) [color= #339933;]: Controls[color= #339933;].Add[color= #009900;](Button2[color= #009900;])

        DataGridView1[color= #339933;].Size [color= #339933;]= [color= #000000; font-weight: bold;]New Size[color= #009900;](Width [color= #339933;]- [color= #cc66cc;]5[color= #339933;], Height [color= #339933;]- [color= #009900;](Button1[color= #339933;].Height [color= #339933;]+ [color= #cc66cc;]50[color= #009900;])[color= #009900;])

        DataGridView1[color= #339933;].Location [color= #339933;]= [color= #000000; font-weight: bold;]New Point[color= #009900;]([color= #cc66cc;]0[color= #339933;], [color= #cc66cc;]0[color= #009900;])

        DataGridView1[color= #339933;].Anchor [color= #339933;]= [color= #cc66cc;]15

        Controls[color= #339933;].Add[color= #009900;](DataGridView1[color= #009900;])

    [color= #990000;]End Sub

 

    [color= #000000; font-weight: bold;]Private Sub Button1_Click[color= #009900;](ByVal Sender [color= #b1b100;]As [color= #990000;]System[color= #339933;].Object[color= #339933;], [color= #990000;]_

    ByVal E [color= #b1b100;]As [color= #990000;]System[color= #339933;].EventArgs[color= #009900;]) Handles Button1[color= #339933;].Click

        Dim OP [color= #b1b100;]As [color= #000000; font-weight: bold;]New OpenFileDialog

        [color= #b1b100;]If OP[color= #339933;].ShowDialog [color= #339933;]= [color= #cc66cc;]1 Then

            DataGridView1[color= #339933;].Rows[color= #339933;].Clear[color= #009900;]([color= #009900;])

            Dim Lines[color= #009900;]([color= #009900;]) [color= #b1b100;]As String [color= #339933;]= [color= #990000;]File[color= #339933;].ReadAllLines[color= #009900;](OP[color= #339933;].FileName[color= #009900;])

            [color= #b1b100;]For [color= #990000;]Each Line [color= #b1b100;]As String In Lines

                DataGridView1[color= #339933;].Rows[color= #339933;].Add[color= #009900;](Line[color= #339933;].[color= #990000;]Split[color= #009900;]([color= #0000ff;]","[color= #009900;])[color= #009900;])

            [color= #990000;]Next

        [color= #990000;]End [color= #b1b100;]If

    [color= #990000;]End Sub

 

    [color= #000000; font-weight: bold;]Private Sub Button2_Click[color= #009900;](ByVal Sender [color= #b1b100;]As [color= #990000;]System[color= #339933;].Object[color= #339933;], [color= #990000;]_

    ByVal E [color= #b1b100;]As [color= #990000;]System[color= #339933;].EventArgs[color= #009900;]) Handles Button2[color= #339933;].Click

        Dim SV [color= #b1b100;]As [color= #000000; font-weight: bold;]New SaveFileDialog

        [color= #b1b100;]If SV[color= #339933;].ShowDialog [color= #339933;]= [color= #cc66cc;]1 Then

            Dim St [color= #b1b100;]As [color= #000000; font-weight: bold;]New StreamWriter[color= #009900;](SV[color= #339933;].FileName[color= #339933;], [color= #000000; font-weight: bold;]False[color= #009900;])

            [color= #b1b100;]For [color= #990000;]Each DGVR [color= #b1b100;]As DataGridViewRow In DataGridView1[color= #339933;].Rows

                [color= #b1b100;]If Not DGVR[color= #339933;].Cells[color= #009900;]([color= #cc66cc;]0[color= #009900;])[color= #339933;].Value [color= #339933;]= String[color= #339933;].[color= #990000;]Empty Then

                    Dim Line [color= #b1b100;]As String [color= #339933;]= String[color= #339933;].[color= #990000;]Empty

                    [color= #b1b100;]For I [color= #b1b100;]As Integer [color= #339933;]= [color= #cc66cc;]0 To [color= #cc66cc;]3

                        Line [color= #339933;]&= DGVR[color= #339933;].Cells[color= #009900;](I[color= #009900;])[color= #339933;].Value [color= #339933;]& [color= #0000ff;]","

                    [color= #990000;]Next

                    Line [color= #339933;]&= DGVR[color= #339933;].Cells[color= #009900;]([color= #cc66cc;]4[color= #009900;])[color= #339933;].Value

                    St[color= #339933;].WriteLine[color= #009900;](Line[color= #009900;])

                [color= #990000;]End [color= #b1b100;]If

            [color= #990000;]Next

            St[color= #339933;].Close[color= #009900;]([color= #009900;])

        [color= #990000;]End [color= #b1b100;]If

    [color= #990000;]End Sub

 

[color= #990000;]End [color= #000000; font-weight: bold;]Class

هل يمكنك ادراج جميع الخصائص المطوبة للملف ؟

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#8

:blush:

على فكره دراستنا مره مبتدئه وماتعمقنا بهالاشيا

مدري بس احس اكوادك ابد ماقد مرت علي ولافهمتها

بوريك شي من اللي اخذناه عن الفايل يمكن توصلك فكرة تعاملنا مع الاكواد

بالمرفقات

حنا كذا اخذنا طريقة الفتح والانشاء والقراءه والكتابه

بس مااخذنا شي عن الحذف او التعديل على ملف موجود مسبقا

وهذا اللي سالت عنه

files.zip

#9

جاري التحميل ......

يمكنك الاستغناء عن تلك المطالب بإستخدام الـ DataGridView وإعادة كتابة الملف من جديد بعد فتحه .

إذا قمت بتجربة الـ Code المرفق, وجربت الضغط على ( Delete ) بعد إختيار صف ما ( ستجدين أن الصف قد حذف ) وبالنسبة للتعديل وإنشاء صف جديد, كل ذلك يوفره لك الـ DataGridView وإعادة كتابة الملف :) .

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 1 يناير 2009 في 21:11

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#10

حاولت تحميل الملف 3 مرات, لكنه يحمل الخطأ ( Unexpected end of archive ) ؟.

رجاءً حوالي تلخيص الفكرة ( الكود ) الذي تريدين عرضه لنا .

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#11

نسخت الكود بس ماضبط لي شي بالرن :(

كمان انا مو فاهمه ليه هالاكواد اصلا

اتمنى من المرفق تعرفت على بساطة طريقتنا

احس طريقتك حقت محترفين وانا بعيده عنها :(

#13

اعتذر على التأخر ( السبب : مشاكل في الاتصال ), لكن وبحمد الله تم الإنتهاء .

_______________________________________________

عند اختبار البرنامج عليك إدخال ( Tala ) في الـ ( Teacher Name ) و ( 1234 ) في الـ ( Password ) والضغط على ( OK ) لتسجيل الدخول كـ( استاذ ) .

أو يمكنك الضغط على ( OK ) بدون إدخال اي من البيانات, لتسجيل الدخول كـ( طالب ) .

WindowsApplication1_1.zip

تم تعديل هذه المشاركة بواسطة Bashar Rabat في 2 يناير 2009 في 02:06

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#14

يطلب رقم سري لما افتح الفيديو

الخام الرئيسي مايفتح

ورابط الاحتياط يطلب رقم سري ايش احط فيه؟

#15

مرحبا بشار

يعطيك الف الف عافيه

مشكور وماقصرت على جهدك واهتمامك

تعبناك معنا

#16

الم تلاحظي أي شيء ( بعد ) ؟!!!

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

#18

مرحباً مرة اخرى .

لقد عدلت المشروع المرفق, التعديلات :

1 - إضاقة خاصيتين ( AnswerIndex, QuestionScore ) الى DataEngine.Question's Class

2 - إضافة متغيرين الى Form1's Class ( AnsweredQuestionCount, Score ) لعرض عدد الأسئلة المجابة والعلامة بعد الإنتهاء من إجابة الأسئلة .

3 - إضافة NumericUpDown Control المسمى NUDAnswerID الى Form1 لجعل الاستاذ يحدد أي من الأجوبة هو صحيح .

4 - إضافة NumericUpDown Control المسمى NUDScore لجعل الاستاذ يحدد علامة السؤال المختار .

5 - تغير طريقة الكتابة والقراءة بالنسبة لملف الاسئلة .

كنت اتمنى أن تقومي انت بهذه التغيرات أو السؤال عنها .

WindowsApplication1_2.rar

The important thing is not so much

that every child should be taught,

as that every child should be given the wish to learn.

مواضيع مشابهة