Click here to Skip to main content
16,005,491 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionPropertyGrid PropertyValueChanged prevent fire of event Pin
InvalidEntry6-Aug-13 20:38
InvalidEntry6-Aug-13 20:38 
AnswerRe: PropertyGrid PropertyValueChanged prevent fire of event Pin
InvalidEntry7-Aug-13 20:56
InvalidEntry7-Aug-13 20:56 
Questioncriar coluna id auto_increment usando pragramaçao vb10 Pin
Pallinho5-Aug-13 12:21
Pallinho5-Aug-13 12:21 
SuggestionRe: criar coluna id auto_increment usando pragramaçao vb10 Pin
Richard MacCutchan5-Aug-13 20:52
mveRichard MacCutchan5-Aug-13 20:52 
AnswerRe: criar coluna id auto_increment usando pragramaçao vb10 Pin
Bernhard Hiller5-Aug-13 22:59
Bernhard Hiller5-Aug-13 22:59 
Questionclacultor Pin
eswaresh4-Aug-13 20:02
eswaresh4-Aug-13 20:02 
AnswerRe: clacultor Pin
Richard MacCutchan4-Aug-13 21:01
mveRichard MacCutchan4-Aug-13 21:01 
AnswerRe: clacultor Pin
anoop.palakkal6-Aug-13 21:10
anoop.palakkal6-Aug-13 21:10 
VB
<pre lang="vb"><pre lang="vb"><pre lang="vb">
Hi you can check the below code to create a simple calculator with 4 functionalities.
VB
Public Class frmcalculator
    Dim Operand1 As Double
    Dim Operand2 As Double
    Dim [Operator] As String

    Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click, btn2.Click, btn3.Click, btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click, Button2.Click
        txtsource.Text = txtsource.Text & sender.text
    End Sub

    Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        txtsource.Text = ""
    End Sub

    Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
        Operand1 = Val(txtsource.Text)
        txtsource.Text = ""
        txtsource.Focus()
        [Operator] = "+"
    End Sub


    Private Sub btndecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If InStr(txtsource.Text, ".") > 0 Then
            Exit Sub
        Else
            txtsource.Text = txtsource.Text & "."
        End If
    End Sub

    Private Sub btnequals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim Result As Double
        Operand2 = Val(txtsource.Text)

        'If [Operator] = "+" Then
        '    Result = Operand1 + Operand2
        'ElseIf [Operator] = "-" Then
        '    Result = Operand1 - Operand2
        'ElseIf [Operator] = "/" Then
        '    Result = Operand1 / Operand2
        'ElseIf [Operator] = "*" Then
        '    Result = Operand1 * Operand2
        'End If

        Select Case [Operator]
            Case "+"
                Result = Operand1 + Operand2
                MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result")
                txtsource.Text = Result.ToString("#,###.00")
            Case "-"
                Result = Operand1 - Operand2
                MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result")
                txtsource.Text = Result.ToString("#,###.00")
            Case "/"
                Result = Operand1 / Operand2
                MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result")
                txtsource.Text = Result.ToString("#,###.00")
            Case "*"
                Result = Operand1 * Operand2
                MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result")
                txtsource.Text = Result.ToString("#,###.00")
        End Select

        txtsource.Text = Result.ToString("#,###.00")

    End Sub

    Private Sub btnminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnminus.Click
        Operand1 = Val(txtsource.Text)
        txtsource.Text = ""
        txtsource.Focus()
        [Operator] = "-"
    End Sub

    Private Sub btnmultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmultiply.Click
        Operand1 = Val(txtsource.Text)
        txtsource.Text = ""
        txtsource.Focus()
        [Operator] = "*"
    End Sub

    Private Sub btndivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndivide.Click
        Operand1 = Val(txtsource.Text)
        txtsource.Text = ""
        txtsource.Focus()
        [Operator] = "/"
    End Sub

    Private Sub btnaddminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        txtsource.Text = -1 * txtsource.Text
    End Sub
    Private Sub btnx_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnx.Click
        Dim convert As Single
        If txtsource.Text <> 0 Then
            convert = 1 / Val(txtsource.Text)
            txtsource.Text = convert
        End If
    End Sub
    Private Sub frmcalculator_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Enter Then
            Call btnequals_Click(sender, e)
        End If
    End Sub


    Private Sub frmcalculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

    End Sub

End Class
AnswerRe: clacultor Pin
Abhinav S7-Aug-13 1:45
Abhinav S7-Aug-13 1:45 
Questionsearch for date inf vb.net from excel to datagrid Pin
hendrikbez1-Aug-13 21:15
hendrikbez1-Aug-13 21:15 
AnswerRe: search for date inf vb.net from excel to datagrid Pin
Mycroft Holmes4-Aug-13 21:10
professionalMycroft Holmes4-Aug-13 21:10 
GeneralRe: search for date inf vb.net from excel to datagrid Pin
Richard MacCutchan4-Aug-13 23:26
mveRichard MacCutchan4-Aug-13 23:26 
GeneralRe: search for date inf vb.net from excel to datagrid Pin
Mycroft Holmes4-Aug-13 23:35
professionalMycroft Holmes4-Aug-13 23:35 
GeneralRe: search for date inf vb.net from excel to datagrid Pin
hendrikbez5-Aug-13 20:27
hendrikbez5-Aug-13 20:27 
QuestionVB.net connect database MySQL online Pin
manoph30-Jul-13 21:49
manoph30-Jul-13 21:49 
AnswerRe: VB.net connect database MySQL online Pin
Eddy Vluggen31-Jul-13 8:54
professionalEddy Vluggen31-Jul-13 8:54 
GeneralRe: VB.net connect database MySQL online Pin
manoph31-Jul-13 23:36
manoph31-Jul-13 23:36 
GeneralRe: VB.net connect database MySQL online Pin
Eddy Vluggen1-Aug-13 9:03
professionalEddy Vluggen1-Aug-13 9:03 
QuestionReport with Crystal Report Pin
Biplob Singha Shee28-Jul-13 21:42
Biplob Singha Shee28-Jul-13 21:42 
SuggestionRe: Report with Crystal Report Pin
ZurdoDev9-Aug-13 8:01
professionalZurdoDev9-Aug-13 8:01 
QuestionDo I need to implement Dispose() ? Pin
David Mujica26-Jul-13 5:31
David Mujica26-Jul-13 5:31 
AnswerRe: Do I need to implement Dispose() ? Pin
Richard Deeming26-Jul-13 5:41
mveRichard Deeming26-Jul-13 5:41 
GeneralRefactoring my code now Pin
David Mujica26-Jul-13 8:03
David Mujica26-Jul-13 8:03 
QuestionCreate Dynamic Label with Drag and Drop Function Pin
Val Gerald Dela Cruz24-Jul-13 14:53
Val Gerald Dela Cruz24-Jul-13 14:53 
AnswerRe: Create Dynamic Label with Drag and Drop Function Pin
Dave Kreskowiak24-Jul-13 17:07
mveDave Kreskowiak24-Jul-13 17:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.