Share My Creation Calculator

Attachments

  • calculator (1).zip
    20.7 KB · Views: 604
Last edited:

ilan

Expert
Licensed User
Longtime User
ok, i will wait

i wanted to control the buttons from the keyboard if you press 1 then button1 should do action...
 

ilan

Expert
Licensed User
Longtime User
found a solution to use my keyboard erel !!
put another textfield and after every click it request focus
this textfield is invisable
now if you click on your keyboard it check what key you pressed and do action

space bar = enter | c = clear | h = history
all other is normal keys

B4X:
Sub keyboard_TextChanged (Old As String, New As String)

Dim ch As String
Dim allowedchar As String
allowedchar = "0123456789+*/-. ch"

ch = keyboard.Text

If allowedchar.Contains(ch) Then

    If ch = 0 Then b0_Action

    If ch = 1 OR ch = 2 OR ch = 3 OR ch = 4 OR ch = 5 OR ch = 6 OR ch = 7 OR ch = 8 OR ch = 9 Then
    btn.Text = ch
    keyboardinput = True
    b_Action
    End If

    If ch = "+" Then bpl_Action
    If ch = "/" Then bd_Action
    If ch = "-" Then bmin_Action
    If ch = "*" Then bmal_Action
    If ch = "." Then bp_Action
    If ch = "c" Then bc_Action
    If ch = " " Then bg_Action
    If ch = "h" Then his_Action

End If

keyboard.Text = ""

keyboard.RequestFocus

End Sub
 

Attachments

  • calculator.zip
    20.7 KB · Views: 464
Last edited:

tsteward

Well-Known Member
Licensed User
Longtime User
Nice. You should give all the digit buttons the same id and then handle them with a single sub.
B4X:
Sub btnDigit_Action
Dim btn As Button = Sender
'work with btn.Text
End Sub
If you give multiple buttons the same ID how can you later alter the text or properties of an individual button?
 

ilan

Expert
Licensed User
Longtime User
what i did is that every button has another TAG and with the sender i ask the value from the tag and use it
how i would like to

again: with the sender you catch the button and then ask for the TAG (= any value you want)
 

stevel05

Expert
Licensed User
Longtime User
If you want to find the button from a tag when it's not in a Click sub you can use the code here
 
Top