Skip to main content

Calculator using Combo Box in VB.NET.(The combo box has options like ‘+’, ‘-’,’*’ and ‘/’. According to user’s choice From combo result will display in label.)

PROPERTIES:
TextBox1,TextBox2
Text(Empty)
ComboBox1
Text+,-,*,/
Items+
-
*
/
CODEING:
Public Class Form1
    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged, ComboBox1.SelectedIndexChanged
        If IsNumeric(TextBox1.Text) And IsNumeric(TextBox2.Text) Then
            ComboBox1.Visible = True
            If ComboBox1.Text = "+" Then
                Label1.Text = TextBox1.Text & " + " & TextBox2.Text & " = " & Val(TextBox1.Text) + Val(TextBox2.Text)
            ElseIf ComboBox1.Text = "-" Then
                Label1.Text = TextBox1.Text & " - " & TextBox2.Text & " = " & Val(TextBox1.Text) - Val(TextBox2.Text)
            ElseIf ComboBox1.Text = "*" Then
                Label1.Text = TextBox1.Text & " * " & TextBox2.Text & " = " & Val(TextBox1.Text) * Val(TextBox2.Text)
            ElseIf ComboBox1.Text = "/" Then
                Label1.Text = TextBox1.Text & " / " & TextBox2.Text & " = " & Val(TextBox1.Text) / Val(TextBox2.Text)
            End If
        Else
            ComboBox1.Visible = False
            Label1.Text = ""
      End If
   End Sub
End Class
DESIGNING:

Comments