I have written the following code:
Public Class Form1
Private Sub CmdCount_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles CmdCount.Click
Dim instotal, sentotal As Integer
Lblins.Text = incount(instota l)
LblCount.Text = incount(sentota l)
End Sub
Private Function incount(ByVal instotal As Integer, ByVal sentotal As Integer) As Integer
Dim pos, lastfound, total As Integer
Dim sSentence As String = Txtsentence.Tex t
Dim sWord As String = txtWord.Text
Dim ignorecase As Boolean
'ignorecase true is not case sensitive
pos = InStr(1, sSentence, sWord, vbTextCompare)
If pos > 0 And ignorecase = True Then
total = 1
lastfound = pos
Do While pos <> 0
pos = InStr(lastfound + 1, sSentence, sWord, vbTextCompare)
If pos > 0 Then
lastfound = pos
instotal = (total + 1)
End If
Loop
Return instotal
End If
If pos > 0 And ignorecase = False Then
total = 1
lastfound = pos
Do While pos <> 0
pos = InStr(lastfound + 1, sSentence, sWord, vbTextCompare)
If pos > 0 Then
lastfound = pos
sentotal = (total + 1)
End If
Loop
Return sentotal
End If
End Function
End Class
I get an "argument not specified" message whenI enter the information in the click event. What do I need to do to get both values printed in two separate labels?
Thank you
Public Class Form1
Private Sub CmdCount_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles CmdCount.Click
Dim instotal, sentotal As Integer
Lblins.Text = incount(instota l)
LblCount.Text = incount(sentota l)
End Sub
Private Function incount(ByVal instotal As Integer, ByVal sentotal As Integer) As Integer
Dim pos, lastfound, total As Integer
Dim sSentence As String = Txtsentence.Tex t
Dim sWord As String = txtWord.Text
Dim ignorecase As Boolean
'ignorecase true is not case sensitive
pos = InStr(1, sSentence, sWord, vbTextCompare)
If pos > 0 And ignorecase = True Then
total = 1
lastfound = pos
Do While pos <> 0
pos = InStr(lastfound + 1, sSentence, sWord, vbTextCompare)
If pos > 0 Then
lastfound = pos
instotal = (total + 1)
End If
Loop
Return instotal
End If
If pos > 0 And ignorecase = False Then
total = 1
lastfound = pos
Do While pos <> 0
pos = InStr(lastfound + 1, sSentence, sWord, vbTextCompare)
If pos > 0 Then
lastfound = pos
sentotal = (total + 1)
End If
Loop
Return sentotal
End If
End Function
End Class
I get an "argument not specified" message whenI enter the information in the click event. What do I need to do to get both values printed in two separate labels?
Thank you
Comment