DESCRIPTION:
Accept a text from user and If user clicks on find button, show index of the first occurrence of the word given in find textbox. If user clicks replace button, found word should be replaced with the word given for replace.
PROPERTIES:
CODEING:
Accept a text from user and If user clicks on find button, show index of the first occurrence of the word given in find textbox. If user clicks replace button, found word should be replaced with the word given for replace.
PROPERTIES:
Label1 | |
Text | (Empty) |
Label2 | |
Text | Find Text |
Label3 | |
Text | Replace Text |
Button1 | |
Text | FIND |
Button2 | |
Text | REPLACE |
Public Class Form1
Dim i As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = InputBox("Enter the Text...")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
i = Label1.Text.IndexOf(TextBox1.Text)
If i = -1 Or TextBox1.Text = "" Then
MsgBox(TextBox1.Text & " Not Found.")
Else
MsgBox("Index of first occurrence of " & TextBox1.Text & " is: " & (i + 1))
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
i = Label1.Text.IndexOf(TextBox1.Text)
If i = -1 Or TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("word Exist Or Input Both Box")
Else
MsgBox(Label1.Text & " is update To " & Label1.Text.Replace(TextBox1.Text, TextBox2.Text))
Label1.Text = Label1.Text.Replace(TextBox1.Text, TextBox2.Text)
End If
End Sub
End Class
DESIGNING:Dim i As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = InputBox("Enter the Text...")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
i = Label1.Text.IndexOf(TextBox1.Text)
If i = -1 Or TextBox1.Text = "" Then
MsgBox(TextBox1.Text & " Not Found.")
Else
MsgBox("Index of first occurrence of " & TextBox1.Text & " is: " & (i + 1))
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
i = Label1.Text.IndexOf(TextBox1.Text)
If i = -1 Or TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("word Exist Or Input Both Box")
Else
MsgBox(Label1.Text & " is update To " & Label1.Text.Replace(TextBox1.Text, TextBox2.Text))
Label1.Text = Label1.Text.Replace(TextBox1.Text, TextBox2.Text)
End If
End Sub
End Class
Comments
Post a Comment