منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[VB.NET] هذا الخطأ في هذا الكود - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : [VB.NET] هذا الخطأ في هذا الكود (/showthread.php?tid=30847)



هذا الخطأ في هذا الكود - mac9 - 12-08-19

السلام عليكم ورحمة الله 
عيدكم مبارك ان شاء الله 

ممكن حل لهذا الكود . 
كود :
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       Dim arr As Array = VPN()
       If arr.GetValue(0) = True Then
           MsgBox(String.Format("
name: {0}
address: {1}
description: {2}", arr.GetValue(1), arr.GetValue(2), arr.GetValue(3)))

       Else
           MsgBox("لايوجد اتصال")
       End If
   End Sub

ما هو الحل 
هذه صورة الخطأ


وهذا الكود كامل 

كود :
Public Class Form1
   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       Dim arr As Array = VPN()
       If arr.GetValue(0) = True Then
           MsgBox(String.Format("
name: {0}
address: {1}
description: {2}", arr.GetValue(1), arr.GetValue(2), arr.GetValue(3)))

       Else
           MsgBox("لايوجد اتصال")
       End If
   End Sub
   Private Function VPN() As Array
       Dim nic As Net.NetworkInformation.NetworkInterface() = Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces
       If Not nic.Length < 0 And nic IsNot Nothing Then
           For Each netadapter As Net.NetworkInformation.NetworkInterface In nic
               'MsgBox(netadapter.Name)
               If netadapter.Name.ToLower.Trim.Contains("vpn") Then ' Or netadapter.Name.Equals("openVPN") ?
                   If netadapter.OperationalStatus = Net.NetworkInformation.OperationalStatus.Up Then
                       For Each addr In netadapter.GetIPProperties().UnicastAddresses
                           If addr.Address.AddressFamily = Net.Sockets.AddressFamily.InterNetwork Then
                               Return {True, netadapter.Name, addr.Address.ToString, netadapter.Description}
                           End If
                       Next
                   End If
               End If
           Next
       End If
       Return {False, Nothing, Nothing, Nothing}
   End Function
End Class



RE: هذا الخطأ في هذا الكود - ابراهيم ايبو - 12-08-19

السلام عليكم .. اضحى مبارك
تفضل اخي 
كود :
   Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
       Dim arr As Array = VPN()
       If arr.GetValue(0) = True Then
           MsgBox(String.Format("name: {0}address: {1}description: {2}", arr.GetValue(1), arr.GetValue(2), arr.GetValue(3)))

       Else
           MsgBox("لايوجد اتصال")
       End If
   End Sub




RE: هذا الخطأ في هذا الكود - الرائد - 13-08-19

(12-08-19, 04:55 PM)ابراهيم ايبو كتب :
السلام عليكم .. اضحى مبارك
تفضل اخي 
كود :
   Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
       Dim arr As Array = VPN()
       If arr.GetValue(0) = True Then
           MsgBox(String.Format("name: {0}address: {1}description: {2}", arr.GetValue(1), arr.GetValue(2), arr.GetValue(3)))

       Else
           MsgBox("لايوجد اتصال")
       End If
   End Sub


فيجوال بيسك صراحة تختلف عن لغات البرمجة الاخرى 
فكما لاحظت انها لاتقبل الدوال الغير متممة في سطر جديد 
لكن مثلا في بايثون لا نعاني من هاته المشاكل فهو امر عادي