25-12-14, 07:48 AM
السلام عليكم ورحمة الله وبركاته
بعض الاحيان اجد بعض الاكواد غير مرتبة مثل هذا الكود
مثلا لوقمت بنسخة ووضعه داخل محرر الفيجوال بيسك راح يطلع لك اخطاء بسبب ان الكود صار بسطرين وغير مرتب ولكي يعمل لابد من اعادة ترتيبه من جديد
السؤال هو كيف ارتب الكود واخليه منظم ويظهر هكذا ويتعرف المحرر على الكود بشكل صحيح
بعض الاحيان اجد بعض الاكواد غير مرتبة مثل هذا الكود
مثلا لوقمت بنسخة ووضعه داخل محرر الفيجوال بيسك راح يطلع لك اخطاء بسبب ان الكود صار بسطرين وغير مرتب ولكي يعمل لابد من اعادة ترتيبه من جديد
PHP كود :
Private Sub Populate(ByVal path As String) Try ListView1.Items.Clear() ComboBox1.Text = path Dim lb As New ListBox For Each str As String In My.Computer.FileSystem.GetDirectories(path) lb.Items.Add(str) NexFor Each str As String In My.Computer.FileSystem.GetFiles(path) lb.Items.Add(str) Next ListView1.Items.Add("...") For Each item In lb.Items Dim NewItem As New ListViewItem If My.Computer.FileSystem.FileExists(item.ToString) Then Dim info As New System.IO.FileInfo(item.ToString) NewItem.Text = item.ToString NewItem.SubItems.Add(info.Length) NewItem.SubItems.Add(info.CreationTime) NewItem.SubItems.Add(info.LastWriteTime) Else Dim info As New System.IO.DirectoryInfo(item.ToString) NewItem.Text = item.ToString NewItem.SubItems.Add("Directory") NewItem.SubItems.Add(info.CreationTime) NewItem.SubItems.Add(info.LastWriteTime) End If ListView1.Items.Add(NewItem) Next ComboBox1.Items.Add(path) Catch ex As Exception If path.EndsWith("My Documents") Then path = My.Computer.FileSystem.SpecialDirectories.MyDocuments Populate(path) ElseIf path.EndsWith("My Pictures") Then path = My.Computer.FileSystem.SpecialDirectories.MyPictures Populate(path) ElseIf path.EndsWith("My Music") Then path = My.Computer.FileSystem.SpecialDirectories.MyMusic Populate(path) End If End Try End Sub Private Sub ListView1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick If My.Computer.FileSystem.FileExists(ListView1.FocusedItem.Text) Then Process.Start(ListView1.FocusedItem.Text) Else If ListView1.FocusedItem.Text = "..." Then Try Populate(My.Computer.FileSystem.GetParentPath(ComboBox1.Text)) Catch ex As Exception MsgBox("You can't get any farther back than a drive! (" & ComboBox1.Text & ")") End Try Else Populate(ListView1.FocusedItem.Text) End If End If End Sub Private Sub ComboBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown If e.KeyCode = Keys.Enter Then Try Populate(ComboBox1.Text) Catch ex As Exception MsgBox(ComboBox1.Text & " does not exist on this system as a directory. Check spelling.") End Try End If End Sub
End Class
السؤال هو كيف ارتب الكود واخليه منظم ويظهر هكذا ويتعرف المحرر على الكود بشكل صحيح
PHP كود :
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Populate(ComboBox1.Text)
End Sub
اثنان لا يتعلمان المتكبر والخجول
اللهم علمنا ما ينفعنا و انفعنا بما علمتنا وَ زِدْنا علماً
اللهم علمنا ما ينفعنا و انفعنا بما علمتنا وَ زِدْنا علماً