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

لذلك قمت بكتابة الكلاس التالي بحيث يمكن استخدامه لإجابة سؤالك
الكلاس من الممكن تطويره سواء باستخدام Linq او بأي اسلوب اخر او يمكن استخدامه كما هو

PHP كود :
Public Class CounterContext

    Private 
Const sep As String " "c
    Private _values 
As List(Of String)
 
   Private _keys As List(Of Integer)
 
   Private _current As String

    Public Sub 
New(As String)
 
       _current s
    End Sub

    Protected ReadOnly Property Values
() As List(Of String)
 
       Get
            If Me
._values Is Nothing Then
                Me
._values = New List(Of String)()
 
               If Not String.IsNullOrEmpty(_currentThen
                    For Each current 
As String In _current.Split(sep)
 
                       If Not _values.Contains(currentThen
                            _values
.Add(current)
 
                       End If
 
                   Next
                End 
If
 
           End If
 
           Return Me._values
        End Get
    End Property

    Protected ReadOnly Property Keys
() As List(Of Integer)
 
       Get
            If Me
._keys Is Nothing Then
                Me
._keys = New List(Of Integer)()
 
               If Not String.IsNullOrEmpty(_currentThen
                    For Each v 
As String In Values
                        Dim key 
As Integer 0
                        For Each s 
As String In _current.Split(sep)
 
                           If v s Then
                                key 
+= 1
                            End 
If
 
                       Next
                        _keys
.Add(key)
 
                   Next
                End 
If
 
           End If
 
           Return Me._keys
        End Get
    End Property

    Public ReadOnly Property Counter 
As String
        Get
            Dim _result 
As String ""
 
           For i As Integer 0 To Keys.Count 1
                _result 
+= String.Format("{0}"Keys(i))
 
           Next
            Return _result
        End Get
    End Property

End 
Class 

الإستخدام

PHP كود :
Dim c As CounterContext = New CounterContext(TextBox1.Text)
 
       Dim result As String c.Counter 
الرد }}}
تم الشكر بواسطة: myalsailamy , السندبااد


الردود في هذا الموضوع
حساب عدد الكلمات - بواسطة hano - 28-11-16, 08:28 PM
RE: حساب عدد الكلمات - بواسطة أبو ناصر - 29-11-16, 01:24 AM
RE: حساب عدد الكلمات - بواسطة silverlight - 29-11-16, 04:02 AM


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


يقوم بقرائة الموضوع: