Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 86,260 VB.NET Programmers. There are 1,963 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a VB.NET Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

VB.net code

 
Reply to this topicStart new topic

VB.net code, code to count the number of a particular letter in a text

oyline
post 5 May, 2008 - 09:33 PM
Post #1


New D.I.C Head

*
Joined: 5 May, 2008
Posts: 2



vb

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.gif

This post has been edited by PsychoCoder: 5 May, 2008 - 10:27 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


jayman9
post 6 May, 2008 - 10:42 AM
Post #2


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 5,548

Do you have a question pertaining to the code you posted?
User is online!Profile CardPM
Go to the top of the page
+Quote Post

rshin2020
post 6 May, 2008 - 05:29 PM
Post #3


New D.I.C Head

*
Joined: 5 May, 2008
Posts: 5

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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

lakhanmahajan
post 6 May, 2008 - 11:46 PM
Post #4


New D.I.C Head

*
Joined: 4 May, 2008
Posts: 13

QUOTE(oyline @ 5 May, 2008 - 09:33 PM) *

vb

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.gif

=============================================
Use mid function to do this
for start=1to len(text)
mid("text as string",start,len(text)) compare with particular string
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/16/08 10:06AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month