dcsimg
Results 1 to 3 of 3

Thread: Help, adding memory to my calculator

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    1

    Help, adding memory to my calculator

    Hello, first time posting.

    Can someone please help me adding memory +, - and MRC to my calculator?
    Having a hard time figuring this out.

    Name:  2.jpg
Views: 153
Size:  28.8 KBName:  1.jpg
Views: 139
Size:  38.8 KB

    My codes:
    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub com0_Click()
        txtDisplay = txtDisplay & "0"
    End Sub
    
    Private Sub com1_Click()
        txtDisplay = txtDisplay & "1"
    End Sub
    Private Sub com2_Click()
        txtDisplay = txtDisplay & "2"
    End Sub
    Private Sub com3_Click()
        txtDisplay = txtDisplay & "3"
    End Sub
    Private Sub com4_Click()
        txtDisplay = txtDisplay & "4"
    End Sub
    Private Sub com5_Click()
        txtDisplay = txtDisplay & "5"
    End Sub
    Private Sub com6_Click()
        txtDisplay = txtDisplay & "6"
    End Sub
    Private Sub com7_Click()
        txtDisplay = txtDisplay & "7"
    End Sub
    Private Sub com8_Click()
        txtDisplay = txtDisplay & "8"
    End Sub
    Private Sub com9_Click()
        txtDisplay = txtDisplay & "9"
    End Sub
    Private Sub comPluss_Click()
        txtDisplay = txtDisplay & "+"
    End Sub
    Private Sub comMinus_Click()
        txtDisplay = txtDisplay & "-"
    End Sub
    Private Sub comDiv_Click()
        txtDisplay = txtDisplay & "/"
    End Sub
    Private Sub comGange_Click()
        txtDisplay = txtDisplay & "*"
    End Sub
    Private Sub comClear_Click()
        txtDisplay = txtDisplay & ""
    End Sub
    Private Sub comMpluss_Click()
        txtDisplay = txtDisplay & ""
    End Sub
     
    Private Sub comMminus_Click()
        txtDisplay = txtDisplay & ""
    End Sub
     
    Private Sub comMRC_Click()
        txtDisplay = txtDisplay & ""
    End Sub
    
    Private Sub comDesimal_Click()
        txtDisplay = txtDisplay & ","
    End Sub
    
    
    Private Sub comLik_Click()
        Dim i As Integer
        Dim op As String
        Dim v1 As Long, v2 As Long, v As Long
        Dim M As Integer
        
        
        For i = 1 To Len(txtDisplay)
            op = Mid(txtDisplay, i, 1)
            If op < "0" Or op > "9" Then
                Exit For
            End If
        Next i
        v1 = Left(txtDisplay, i - 1)
        v2 = Right(txtDisplay, Len(txtDisplay) - i)
        If op = "+" Then
            v1 = v1 + v2
        ElseIf op = "-" Then
            v1 = v1 - v2
        ElseIf op = "*" Then
            v1 = v1 * v2
        ElseIf op = "/" Then
            v1 = v1 / v2
        End If
        txtDisplay = v1
        
        
    End Sub
    Last edited by si_the_geek; Sep 11th, 2018 at 09:08 AM. Reason: added Code tags

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,118

    Re: Help, adding memory to my calculator

    Welcome to VBForums

    Based on the "Option Compare Database", I'm assuming this is in the VB Editor inside Access... so thread moved from the 'VB.Net' forum to the 'Office Development/VBA' forum.


    To have a memory, create a variable (at the top of the form, outside of any sub/function) to store the value. You can then use that variable as appropriate when the relevant buttons are pressed.

  3. #3
    Lively Member
    Join Date
    Aug 2009
    Location
    Nairobi
    Posts
    64

    Re: Help, adding memory to my calculator

    You can also go to Project's Properties, then settings then add your variables as desired. Use "My.Setings.Save" for retrieval after application exits.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width