Membuat kalkulator pada console application Visual Basic .Net

alfa6661
- December 05, 2011
0 (0 votes)
Rate :
Cara Membuat kalkulator pada console application Visual Basic .Net

Artikel berikut ini merupakan potongan syntax sederhana untuk membuat sebuah kalkulator pada console application Visual Basic .Net

Syntax

Sub Main()
 
XX:    
        Console.Clear()
        Console.Write("Bilangan 1 : ")
 
        Dim Angka1 As Double
        Angka1 = Console.ReadLine()
        Console.Write("Operasi (x,/,+,-) : ")
        Dim Operasi As String
        Operasi = Console.ReadLine()
        Console.Write("Bilangan 2 : ")
        Dim Angka2 As Double
        Angka2 = Console.ReadLine()
 
        Select Case UCase(Operasi)
            Case "X"
                Console.WriteLine()
                Console.WriteLine("--------------------------")
                Console.WriteLine()
                Console.Write("Hasil : ")
                Console.WriteLine(Angka1 * Angka2)
            Case "/"
                Console.WriteLine()
                Console.WriteLine("--------------------------")
                Console.WriteLine()
                Console.Write("Hasil : ")
                Console.WriteLine(Angka1 / Angka2)
            Case "+"
                Console.WriteLine()
                Console.WriteLine("--------------------------")
                Console.WriteLine()
                Console.Write("Hasil : ")
                Console.WriteLine(Angka1 + Angka2)
            Case "-"
                Console.WriteLine()
                Console.WriteLine("--------------------------")
                Console.WriteLine()
                Console.Write("Hasil : ")
                Console.WriteLine(Angka1 - Angka2)
            Case Else
                Console.WriteLine()
                Console.WriteLine("Anda salah memasukkan operasi")
        End Select
 
        Console.WriteLine()
        Console.WriteLine("----------------------------------------")
        Console.Write("Ulangi lagi? (Y/T): ")
        Dim xUlang As String
        xUlang = Console.ReadLine()
 
        Select Case UCase(xUlang)
            Case "Y"
                GoTo XX
            Case Else
                Console.Write("Terima Kasih")
                Console.ReadLine()
        End Select
 
End Sub

Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter

– Eric S. Raymond

Have a better explanation?

If you have comments about this post. Please write your comments below

No comments associated with this article