Public Class Form1
Public Class Form1
Dim nChar As Integer
Dim nWord As Integer
Dim nSpace As Integer
Dim nSentence As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim c As String = txtPhrase.Text
nChar = textLength(c)
nWord = CountWords(c)
nSentence = sentenceCount(c)
nSpace = wordSpace(c)
updateChar()
End Sub
Private Sub updateChar()
TextBox1.Text = nChar
TextBox2.Text = nWord
TextBox3.Text = nSentence
TextBox4.Text = nSpace
End Sub
Private Function textLength(ByVal str As String) As String
Return str.Length
End Function
Public Function CountWords(ByVal value As String) As Integer
Return value.Split(" ").Count()
End Function
Public Function wordSpace(ByVal space As String) As String
Dim y As Integer
y = space.Split(" ").Count
y -= 1
Return y
End Function
Public Function sentenceCount(ByVal sentence As String) As String
Dim x As Integer
x = sentence.Split(".").Count()
x -= 1
Return x
End Function
End Class
Monday, May 9, 2011
Methods
Here is how Methods are done using different Functions .
Labels:
Code Writing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment