Skip to main content

Count Words in String in VB.NET | Check String is Palindrome in VB.NET | Count words starts from “a” character.

PROPERTIES:
Button1
TextPalindrom
TextBox1
Text(Empty)
CODEING:
Imports System.Char
Public Class Form1
    Dim s As String
    Dim i As Integer = 0
    Dim w As Integer = 0
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        For Each c As Char In TextBox1.Text
            s = c & s
        Next c
        If s = TextBox1.Text Then
            MsgBox(s & " is Palindrom")
        Else
            MsgBox(TextBox1.Text & " is not Palindrom")
        End If
        Dim s1() As String = TextBox1.Text.ToLower.Split(" ")
        While i < s1.Length()
            If s1(i).StartsWith("a") Then
                w += 1
            End If
            i += 1
        End While
        MsgBox(s1.Length() & " words in string" & vbNewLine & w & " words starts from a character")
    End Sub
End Class
DESIGNING:



Comments