تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
حساب عدد الكلمات
#1
السلام عليكم  انا بحاجة الكود بلغه  vb.net
عندما ما ادخل  في الtextbox1 الجمله my comp my doc يقوم بحساب  أن كلمه my تكررت مرتان  وكلمه  comp مره واحده  و كلمه doc مره  فيخرج في الtextbox2  عددها  على شكل  ألرقم 211
الرد }}}
تم الشكر بواسطة:
#2
بسم الله الرحمن الرحيم ، الكود التالي ان شاء الله يفي بالغرض 
PHP كود :
Public Class Form1
    Dim x 
As Integer
    Dim myList 
As New List(Of Integer)

 
   Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click
        x 
0
        myList
.Clear()
 
       TextBox2.Clear()

 
       Dim arr As Array = TextBox1.Text.Split(" ").ToArray

        For i 
0 To arr.Length 1
            If myList
.Contains(iThen Continue For
 
           For j 0 To arr.Length 1
                If arr
(i) = arr(jThen
                    x 
+= 1
                    myList
.Add(j)
 
               End If

 
           Next
            TextBox2
.Text &= x
            x 
0
        Next
    End Sub
End 
Class 


الملفات المرفقة
.rar   WindowsApplication1.rar (الحجم : 64.78 ك ب / التحميلات : 78)
الرد }}}
تم الشكر بواسطة: amgad525 , myalsailamy , myalsailamy
#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 , السندبااد



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


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم