Write a Vb.net program to accept sentences in text box and count the number of words and display the count in message box.
Form:-
Program:-
Public Class slip11
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim n As String
Dim count As Integer
n = TextBox1.Text
For i As Integer = 0 To n.Length - 1
If " " = n(i) Then
count = count + 1
End If
Next
count = count + 1
MsgBox("Total words in sentence: " + CStr(count))
End Sub
End Class
Output:-
Design:-
1) Take Textbox, Label, Button on Design form.
2) Set text on label and button.
Note - Set startup form's application type as Windows Form Application
0 Comments