Create a form having a textbox and three buttons for splitting the
name, initial of the name. Display the result in message box. For
example enter Ashish Rameshbhai patel split this name as
“Ashish”,“Ramesh bhai” and “patel”. In the initial will be A.R.PATEL.
Public Class app5
Dim s As String = ""
Dim i As Integer
Dim a As Integer
Dim fn, mn, ln As String
Dim str1(2) As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
fn = ""
mn = ""
ln = ""
a = 0
s = TextBox1.Text
For i = 0 To s.Length - 1
If Asc(s(i)) = 32 Then
a += 1
End If
If a = 0 Then
fn += s(i)
ElseIf a = 1 Then
mn += s(i)
ElseIf a = 2 Then
ln += s(i)
End If
Next
Label5.Text = fn
Label6.Text = mn
Label7.Text = ln
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
fn = ""
mn = ""
ln = ""
a = 0
s = TextBox1.Text
For i = 0 To s.Length - 1
If Asc(s(i)) = 32 Then
a += 1
End If
If a = 0 Then
fn += s(i)
ElseIf a = 1 Then
mn += s(i)
ElseIf a = 2 Then
ln += s(i)
End If
Next
Label4.Text = fn(0) & "." & mn(1) & "." & ln
End Sub
End Class
Made By: Yadav Roshani R. from Third Year of BCA
Comments
Post a Comment