VB .NET
Slip11
Q.1) Write a Vb.net program to accept sentences in text box and count the number of words and display the count in message box. [Marks 20]
Solution
Public Class Slip11
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As String
Dim i, cnt As Integer
a = TextBox1.Text
Dim arr() As Char = a.ToCharArray()
cnt = 1
While i < arr.Length - 1
If arr(i) = " " Then
cnt = cnt + 1
End If
i = i + 1
End While
MsgBox("The total Word:" & cnt)
End Sub
End Class
Tags:
VB .NET