Friday, February 12, 2010

I need to add to my function set to true if the search is case-sensitive and False if it isn鈥檛?

The argument needs to be optional defaulting to true, so that the existing call to the function doesn鈥檛 need to be modified. I also need to add a second button to my form that provides a case-insensitive count. This is what I have so far.





Public Function WordCount(ByVal sInput, ByVal sSentence) As Integer


WordCount = 0





Dim i As Integer





For i = 1 To Len(sSentence)


Debug.Print(Mid(sSentence, i, Len(sInput)))


If Mid(sSentence, i, Len(sInput)) = sInput Then


WordCount = WordCount + 1


End If


Next i





End Function





Private Sub cmdCompare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCompare.Click


Label.Text = WordCount(TextBox1.Text, TextBox2.Text)


End SubI need to add to my function set to true if the search is case-sensitive and False if it isn鈥檛?
Suppose that the third argument is named ';caseSensitive';, you will need add this to the beginning of the function:





''''''''' Beginning of Code


if !caseSensitive then


sInput=toUpper(sInput)


sSentence=toUpper(sSentence)


end if


''''''''' End of Code





Enjoy ;)

No comments:

Post a Comment