VB.net code

code to count the number of a particular letter in a text

Page 1 of 1

3 Replies - 956 Views - Last Post: 06 May 2008 - 11:46 PM Rate Topic: -----

#1 oyline  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-May 08

VB.net code

Posted 05 May 2008 - 09:33 PM

Public Class Form1

    Private Function SplitSentences(ByVal sSourceText As String) As ArrayList

        ' create a local string variable
        ' set to contain the string passed it
        Dim sTemp As String = sSourceText

        ' create the array list that will
        ' be used to hold the sentences
        Dim al As New ArrayList()
        Dim Regex As String


        ' split the sentences with a regular expression
        Dim RegexSentenceParse As String() = _
            Regex.Split(sTemp, "(?<=['""A-Za-z0-9][\.\!\?])\s+(?=[A-Z])")

        ' loop the sentences
        Dim i As Integer = 0
        For i = 0 To RegexSentenceParse.Length - 1
            ' clean up the sentence one more time, trim it,
            ' and add it to the array list
            Dim sSingleSentence As String = _
            RegexSentenceParse(i).Replace(Environment.NewLine, String.Empty)
            al.Add(sSingleSentence.Trim())
        Next

    End Function

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        ListBox1.ClearSelected()
    End Sub
End Class



EDIT: Code tags added => :code:

This post has been edited by PsychoCoder: 05 May 2008 - 10:27 PM


Is This A Good Question/Topic? 0
  • +

Replies To: VB.net code

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: VB.net code

Posted 06 May 2008 - 10:42 AM

Do you have a question pertaining to the code you posted?
Was This Post Helpful? 0
  • +
  • -

#3 rshin2020  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 05-May 08

Re: VB.net code

Posted 06 May 2008 - 05:29 PM

I have a few questions. I'm a begginer so just need some understanding.
1. Why do u use public class form 1?
2. Do u save the program as Form 1?
3. In here :Dim sTemp As String = sSourceText, why do u put = aSourceText? is it an object created or anything?
4. Why do we use imports system? do we import anything? and why do we use modules?
Please explain to me in simple language for me to understand. Thanks alot.
Was This Post Helpful? 0
  • +
  • -

#4 lakhanmahajan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 04-May 08

Re: VB.net code

Posted 06 May 2008 - 11:46 PM

View Postoyline, on 5 May, 2008 - 09:33 PM, said:

Public Class Form1

    Private Function SplitSentences(ByVal sSourceText As String) As ArrayList

        ' create a local string variable
        ' set to contain the string passed it
        Dim sTemp As String = sSourceText

        ' create the array list that will
        ' be used to hold the sentences
        Dim al As New ArrayList()
        Dim Regex As String


        ' split the sentences with a regular expression
        Dim RegexSentenceParse As String() = _
            Regex.Split(sTemp, "(?<=['""A-Za-z0-9][\.\!\?])\s+(?=[A-Z])")

        ' loop the sentences
        Dim i As Integer = 0
        For i = 0 To RegexSentenceParse.Length - 1
            ' clean up the sentence one more time, trim it,
            ' and add it to the array list
            Dim sSingleSentence As String = _
            RegexSentenceParse(i).Replace(Environment.NewLine, String.Empty)
            al.Add(sSingleSentence.Trim())
        Next

    End Function

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        ListBox1.ClearSelected()
    End Sub
End Class



EDIT: Code tags added => :code:

=============================================
Use mid function to do this
for start=1to len(text)
mid("text as string",start,len(text)) compare with particular string
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1