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

مطلوب شرح أكواد فيجول

بدأه noura1 في 29 مايو 2011 · 9 رد · 1,792 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

أرجوا منك شرح هذه الاكواد ,,, وشكراً

        If order = "notepad" Then
            System .Diagnostics. Process .Start ("notepad")
        Else If order = "calc" Then
            System .Diagnostics .Process .Start ("calc ("
        Else  
            MessageBox .Show("Sorry Sir Your Request is not in my hand", order)
        End If
        Mytcpl .Stop() 

        If mysocket .Connected = True Then
            Do While True
                our_Server() 
            Loop
        End If
    End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myth As Thread 
        myth = New Thread(New System.Threading.ThreadStart(AddressOf our_Server))        myth.Start()
    End Sub

    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Try 
            mytcpl.Stop()
            Application.ExitThread()
            Application.Exit()
        Catch ex As Exception 
            MessageBox.Show (ex.Message)
        End Try
    End Sub
End Class

Private mysr As StreamReader
    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        Try
            Dim myclient As TcpClient = New TcpClient(txt_host.Text, 5020)' 
Dim myns As NetworkStream = myclient.GetStream()'
            Dim mysw As StreamWriter = New StreamWriter(myns)' 
            mysw.WriteLine(txt_msg.Text)
            mysw.Close()
            myns.Close()
            myclient.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub
End Class

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean) 
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.label2 = New System.Windows.Forms.Label
        Me.label1 = New System.Windows.Forms.Label
        Me.txt_host = New System.Windows.Forms.TextBox
        Me.button1 = New System.Windows.Forms.Button
        Me.txt_msg = New System.Windows.Forms.TextBox
        Me.Button2 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'label2
        '
        Me.label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(178, Byte))
        Me.label2.Location = New System.Drawing.Point(12, 47)
        Me.label2.Name = "label2"
        Me.label2.Size = New System.Drawing.Size(88, 23)
        Me.label2.TabIndex = 9
        Me.label2.Text = "Your Request"
        '
        'label1
        '
        Me.label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(178, Byte))
        Me.label1.Location = New System.Drawing.Point(12, 15)
        Me.label1.Name = "label1"
        Me.label1.Size = New System.Drawing.Size(80, 23)
        Me.label1.TabIndex = 8
        Me.label1.Text = "Server"
        '
        'txt_host
        '
        Me.txt_host.Location = New System.Drawing.Point(100, 15)
        Me.txt_host.Name = "txt_host"
        Me.txt_host.Size = New System.Drawing.Size(144, 20)
        Me.txt_host.TabIndex = 7
        Me.txt_host.Text = "localhost"
        '
        'button1
        '
        Me.button1.Location = New System.Drawing.Point(169, 79)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(75, 23)
        Me.button1.TabIndex = 6
        Me.button1.Text = "Send"
        '
        'txt_msg
        '
        Me.txt_msg.Location = New System.Drawing.Point(100, 47)
        Me.txt_msg.Name = "txt_msg"
        Me.txt_msg.Size = New System.Drawing.Size(144, 20)
        Me.txt_msg.TabIndex = 5
        Me.txt_msg.Text = "notepad"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(15, 79)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(75, 23)
        Me.Button2.TabIndex = 10
        Me.Button2.Text = "Exit"
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.BackColor = System.Drawing.Color.PaleGreen
        Me.ClientSize = New System.Drawing.Size(255, 114)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.label2)
        Me.Controls.Add(Me.label1)
        Me.Controls.Add(Me.txt_host)
        Me.Controls.Add(Me.button1)
        Me.Controls.Add(Me.txt_msg)
        Me.Name = "Form1"
        Me.Text = "Client Side"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Private WithEvents label2 As System.Windows.Forms.Label
    Private WithEvents label1 As System.Windows.Forms.Label
    Private WithEvents txt_host As System.Windows.Forms.TextBox
    Private WithEvents button1 As System.Windows.Forms.Button
    Private WithEvents txt_msg As System.Windows.Forms.TextBox
    Private WithEvents Button2 As System.Windows.Forms.Button

End Class

الرجاء شرحها

#2

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

اختي طبعا سؤالك مو واضح والكود الاول ناقص بس الغرض منه حسب قيمة المتغير order يقوم البرنامج بفتح الاله الحاسبه او المفكره, اما الثاني يقوم بعمل Stream للكتابه ويعرف عميل بعنوان ومنفذ معين

ومره اخرى حاولي توضحي سؤالك في المرات القادمه ..

.:: Wish to become better and better ::.

#3

ستجدين الشرح في مشاركة الأخ فادي عبدالقادر على الرابط التالي:

/index.php?showtopic=78693&view=findpost&p=430880

سبحان الله وبحمده ... سبحان الله العظيم

#4

اختى الكود الاول كود خاص بملفات النظام يتم من خلاله فتح وورد باد و الاله الحاسبه وشكرا

اليكى ملف به عدة اكواد هامه جدا

http://www.mysterycodes.blogspot.com/

#5

أخي أريد فقط شرح كل سطر ,,, لان لدي مناقشه غدا في مشروع ومن مشروعي جزء يعتمد على الفيجول فقط اريد فائده كل امر

Imports System  ـ
Imports System .Data 
Imports System. Net .Sockets
Imports System.IO 
Imports System .Threading 

Public Class Form1
    Private mytcpl As TcpListener 
    Private mysocket As Socket 

    Private myns As NetworkStream 
    Private mysr As StreamReader 

Private Sub our _Server() 
        mytcpl = New TcpListener(5020)
        mytcpl .Start()
        mysocket = mytcpl .AcceptSocket
        myns = New NetworkStream(mysocket)
        mysr = New StreamReader(myns(
        Dim order As String = mysr.ReadLine))

        If order = "notepad" Then
            System .Diagnostics. Process .Start ("notepad")
        Else If order = "calc" Then
            System .Diagnostics .Process .Start ("calc ("
        Else 
            MessageBox .Show("Sorry Sir Your Request is not in my hand", order)
        End If
        Mytcpl .Stop() 

        If mysocket .Connected = True
            Do While True
                our_Server() 
            Loop
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myth As Thread 
        myth = New Thread(New System.Threading.ThreadStart(AddressOf our_Server))        myth.Start()
    End Sub

    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Try 
            mytcpl.Stop()
            Application.ExitThread()
            Application.Exit()
        Catch ex As Exception 
            MessageBox.Show (ex.Message)
        End Try
    End Sub
End Class

Imports System  
Imports System .Data 
Imports System. Net. Sockets 
Imports System.IO 
Imports System. Threading 
Public Class Form1
    Private mytcpl As TcpListener 
    Private mysocket As Socket 
    Private myns As NetworkStream  
    Private mysr As StreamReader
    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        Try
            Dim myclient As TcpClient = New TcpClient(txt_host.Text, 5020)' 
Dim myns As NetworkStream = myclient.GetStream()'
            Dim mysw As StreamWriter = New StreamWriter(myns)' 
            mysw.WriteLine(txt_msg.Text)
            mysw.Close()
            myns.Close()
            myclient.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub
End Class

 <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean) 'dispose للتخلص من threading
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.label2 = New System.Windows.Forms.Label
        Me.label1 = New System.Windows.Forms.Label
        Me.txt_host = New System.Windows.Forms.TextBox
        Me.button1 = New System.Windows.Forms.Button
        Me.txt_msg = New System.Windows.Forms.TextBox
        Me.Button2 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'label2
        '
        Me.label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(178, Byte))
        Me.label2.Location = New System.Drawing.Point(12, 47)
        Me.label2.Name = "label2"
        Me.label2.Size = New System.Drawing.Size(88, 23)
        Me.label2.TabIndex = 9
        Me.label2.Text = "Your Request"
        '
        'label1
        '
        Me.label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(178, Byte))
        Me.label1.Location = New System.Drawing.Point(12, 15)
        Me.label1.Name = "label1"
        Me.label1.Size = New System.Drawing.Size(80, 23)
        Me.label1.TabIndex = 8
        Me.label1.Text = "Server"
        '
        'txt_host
        '
        Me.txt_host.Location = New System.Drawing.Point(100, 15)
        Me.txt_host.Name = "txt_host"
        Me.txt_host.Size = New System.Drawing.Size(144, 20)
        Me.txt_host.TabIndex = 7
        Me.txt_host.Text = "localhost"
        '
        'button1
        '
        Me.button1.Location = New System.Drawing.Point(169, 79)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(75, 23)
        Me.button1.TabIndex = 6
        Me.button1.Text = "Send"
        '
        'txt_msg
        '
        Me.txt_msg.Location = New System.Drawing.Point(100, 47)
        Me.txt_msg.Name = "txt_msg"
        Me.txt_msg.Size = New System.Drawing.Size(144, 20)
        Me.txt_msg.TabIndex = 5
        Me.txt_msg.Text = "notepad"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(15, 79)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(75, 23)
        Me.Button2.TabIndex = 10
        Me.Button2.Text = "Exit"
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.BackColor = System.Drawing.Color.PaleGreen
        Me.ClientSize = New System.Drawing.Size(255, 114)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.label2)
        Me.Controls.Add(Me.label1)
        Me.Controls.Add(Me.txt_host)
        Me.Controls.Add(Me.button1)
        Me.Controls.Add(Me.txt_msg)
        Me.Name = "Form1"
        Me.Text = "Client Side"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Private WithEvents label2 As System.Windows.Forms.Label
    Private WithEvents label1 As System.Windows.Forms.Label
    Private WithEvents txt_host As System.Windows.Forms.TextBox
    Private WithEvents button1 As System.Windows.Forms.Button
    Private WithEvents txt_msg As System.Windows.Forms.TextBox
    Private WithEvents Button2 As System.Windows.Forms.Button

End Class
#6

لقد حصلت على برنامج مشابهه للبرنامج الاول واخذت شرحه ,,, الله يعطيكم العافيه

ولكن اريد شرح البرنامج 2 و 3

#7

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

اختي الجزء الثاني ناقص, اما الجزء الاخير ماهو الا ملف ال Designer والذي يكون فيه انشاء وضبط خواص الكائنات على الفورم الحالي .. ومره اخرى ارجو التوضيح لأنه مش معقول واحد يشرح كود كبير سطر سطر .. ضروري تستفيدي واذا في مشكله سنساعدك

.:: Wish to become better and better ::.

#8

أخي ,,, لماذا الجزء الثاني ناقص !!! :ohmy:

أنا لم أفهمه الكود الثاني :cry:

#9

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

اختي انتي الي كتبتيه؟!! لأن السطرين السابقه وحسب ماذكرت سابقا تعرف عميل وكذلك Stream للكتابه

.:: Wish to become better and better ::.

#10

البرنامج علشان اتحكم بجهازين واحد سيرفر وثاني عميل

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