Rabu, 03 November 2010

Fungsi String

Dim i As String = "LPKIA"
    Dim a As String = "lpkia"
    Dim jwb As Integer


    Sub balik()
        Console.Clear()
        Console.Write("Awalnya  : " &  i)
        Console.WriteLine()
        Console.Write("hasilnya : " & StrReverse(i))
        Console.ReadKey()
    End Sub

    Sub kecil()
        Console.Clear()
        Console.Write("Awalnya  : " & i)
        Console.WriteLine()
        Console.Write("hasilnya : " & LCase(i))
        Console.ReadKey()
    End Sub

    Sub besar()
        Console.Clear()
        Console.Write("Awalnya  : " & a)
        Console.WriteLine()
        Console.Write("hasilnya : " & UCase(a))
        Console.ReadKey()
    End Sub

    Sub ganti()
        Console.Clear()
        Console.Write("Awalnya  : " & i)
        Console.WriteLine()
        Console.Write("hasilnya : " & Replace(i, "L", "K"))
        Console.ReadKey()
    End Sub

    Sub ubah()
        Console.Clear()
        Console.Write("Awalnya  : " & i)
        Console.WriteLine()
        Console.Write("hasilnya : " & Chr(i))
        Console.ReadKey()
    End Sub

    Sub Main()
        Console.Write("1. Balikan string")
        Console.WriteLine()
        Console.Write("2. Kecilkan string")
        Console.WriteLine()
        Console.Write("3. Besarkan string")
        Console.WriteLine()
        Console.Write("4. Replace string")
        Console.WriteLine()
        Console.Write("5. Ubah string")
        Console.WriteLine()
        Console.Write("6. exit")
        Console.WriteLine()
        Console.Write("pilih ?? ")
        jwb = Console.ReadLine

        If jwb = 1 Then
            balik()
            Main()
        ElseIf jwb = 2 Then
            kecil()
            Main()
        ElseIf jwb = 3 Then
            besar()
            Main()
        ElseIf jwb = 4 Then
            ganti()
            Main()
        ElseIf jwb = 5 Then
            ubah()
            Main()
        Else
            End

        End If

    End Sub


Tidak ada komentar:

Posting Komentar