Senin, 06 Juni 2011

Coding Visual Basic Find and replace

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Me.CheckBox1.Checked = True Then
            Me.TxtInput.Text = Replace(Me.TxtInput.Text, Me.TxtPencarian.Text, Me.TxtSubtitusi.Text, 1, -1, CompareMethod.Binary)
        Else
            Me.TxtInput.Text = Replace(Me.TxtInput.Text, Me.TxtPencarian.Text, Me.TxtPencarian.Text, 1, -1, CompareMethod.Text)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim tmp() As String = Me.TxtInput.Text.Split("")
        If Me.CheckBox1.Checked = True Then
            Me.TxtFrekuensi.Text = Filter(tmp, Me.TxtPencarian.Text, True, CompareMethod.Binary).Length
        Else
            Me.TxtFrekuensi.Text = Filter(tmp, Me.TxtPencarian.Text, True, CompareMethod.Text).Length
        End If
    End Sub
End Class

Tidak ada komentar:

Posting Komentar

Berkomentarlah yang baik..