German Wie rechnet man mit Edittext?

Watchkido1

Active Member
Licensed User
Longtime User
HI

FormelrechnerApps wie "Mathe Experte" aus dem Market haben Eingabemasken.
Du gibst 2 Variablen ein und die App berechnet alle 10 anderen sich ergebenden Variablen. (Und zeigen auch noch den Rechenweg an.)

Jetzt hab ich versucht sowas auch zu erstellen.
Ich habe aber keinen blassen Schimmer wie man es macht das sich aus den 2 Variablen alle anderen ergeben.
Ich meine, ich kann bei Mathe Experte irgendeine der Variablen eingeben und immer errechnet mir die App alle anderen Ergebnisse.

Wie macht man sowas?
6 hoch 6 "If then" Schleifen? :eek:

lg Frank

B4X:
'Activity module 



'edtTextRechner



Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim scvMain As ScrollView
   Dim PanelNb As Int               : PanelNb=9
   Dim PanelHeight As Int            : PanelHeight=180dip
   Dim Formel, Text(10,10) As String    : Formel = "Dreieck"
   Dim i,Zahl(10,10) As Int
   Dim lblTest(10,10) As Label
   Dim edtTest(10) As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
   Dim pnltest(10) As Panel 
   Dim btnTest As Button
   
   scvMain.Initialize(500)
   Activity.AddView(scvMain, 0, 0, 100%x, 100%y)

   
   Dreieck ' Labeltexte abholen
         
   For i=0 To PanelNb-1
      
      
      pnltest(i).Initialize("pnlTest")

      scvMain.Panel.AddView(pnltest(i),0,5dip+i*PanelHeight,100%x,PanelHeight+5)
      pnltest(i).Tag=i
      If (i Mod 2)=1 Then
         pnltest(i).Color=Colors.Red
      Else
         pnltest(i).Color=Colors.Blue
      End If
      
      'Benennung
      lblTest(i,1).Initialize("lblTest")
      pnltest(i).AddView(lblTest(i,1),10dip, 5dip, 45%x, 40dip)
      lblTest(i,1).Tag=i
      lblTest(i,1).TextSize=20
      lblTest(i,1).Text= Text(i,1)
      lblTest(i,1).TextColor = Colors.Black
      lblTest(i,1).Gravity = Gravity.RIGHT
      
      'Formel 1
      lblTest(i,2).Initialize("lblTest")
      pnltest(i).AddView(lblTest(i,2),10dip, 35dip, 45%x, 40dip)
      lblTest(i,2).Tag=i
      lblTest(i,2).TextSize=17
      lblTest(i,2).Text=Text(i,2)
      lblTest(i,2).TextColor = Colors.Black
      lblTest(i,2).Gravity = Gravity.RIGHT
      
      'Formel 2
      lblTest(i,3).Initialize("lblTest")
      pnltest(i).AddView(lblTest(i,3),10dip, 65dip, 45%x, 40dip)
      lblTest(i,3).Tag=i
      lblTest(i,3).TextSize=17
      lblTest(i,3).Text=Text(i,3)
      lblTest(i,3).TextColor = Colors.Black
      lblTest(i,3).Gravity = Gravity.RIGHT
      
      
      'Formel 3
      lblTest(i,4).Initialize("lblTest")
      pnltest(i).AddView(lblTest(i,4),10dip, 95dip, 45%x, 40dip)
      lblTest(i,4).Tag=i
      lblTest(i,4).TextSize=17
      lblTest(i,4).Text=Text(i,4)
      lblTest(i,4).TextColor = Colors.Black
      lblTest(i,4).Gravity = Gravity.RIGHT
      
      'Eingabefeld
      edtTest(i).Initialize("edtTest")
      pnltest(i).AddView(edtTest(i),55%x, 5dip, 35%x, 35dip)'55%x, 70dip, 35%x, 25dip)
      edtTest(i).Tag=i
      edtTest(i).TextSize=15
      edtTest(i).InputType = edtTest(i).INPUT_TYPE_DECIMAL_NUMBERS
   
      'Ergebnis 1
      lblTest(i,5).Initialize("lblTest")
      pnltest(i).AddView(lblTest(i,5),55%x, 40dip, 35%x, 25dip)
      lblTest(i,5).Tag=i&5
      lblTest(i,5).TextSize=17
      lblTest(i,5).Text= Zahl(i,5)
      lblTest(i,5).Color = Colors.LightGray
      lblTest(i,5).TextColor = Colors.Black
            
      'Ergebnis 2       
      lblTest(i,6).Initialize("lblTest")
      pnltest(i).AddView(lblTest(i,6),55%x, 70dip, 35%x, 25dip)
      lblTest(i,6).Tag=i&6
      lblTest(i,6).TextSize=17
      lblTest(i,6).Text=Zahl(i,6)
      lblTest(i,6).Color = Colors.LightGray
      lblTest(i,6).TextColor = Colors.Black   
         
      'Ergebnis 3      
      lblTest(i,7).Initialize("lblTest")
      pnltest(i).AddView(lblTest(i,7),55%x, 100dip, 35%x, 25dip)
      lblTest(i,7).Tag=i&7
      lblTest(i,7).TextSize=17
      lblTest(i,7).Text=Zahl(i,7)
      lblTest(i,7).Color = Colors.LightGray
      lblTest(i,7).TextColor = Colors.Black
'      
'      btnTest.Initialize("btnTest")
'      pnltest(i).AddView(btnTest,240dip, 135dip, 70dip, 40dip)
'      btnTest.Tag=i
'      btnTest.Text="Test "&i
   Next
   scvMain.Panel.Height=PanelNb*PanelHeight+10
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub lblTest_Click ' übernahme der Ergebnisse in edtTest
   Dim Send As Label
   Dim i As Int
   Send=Sender
   Activity.Title="Label "&Send.Tag
   i = Send.Tag
   
   Select i
      
      Case 05
         edtTest(0).Text = lblTest(0,5).Text
      Case 06
         edtTest(0).Text = lblTest(0,6).Text
      Case 07
         edtTest(0).Text = lblTest(0,7).Text
      Case 15
         edtTest(1).Text = lblTest(1,5).Text
      Case 16
         edtTest(1).Text = lblTest(1,6).Text
      Case 17
         edtTest(1).Text = lblTest(1,7).Text
      Case 25
         edtTest(2).Text = lblTest(2,5).Text
      Case 26
         edtTest(2).Text = lblTest(2,6).Text
      Case 27
         edtTest(2).Text = lblTest(2,7).Text
      Case 35
         edtTest(3).Text = lblTest(3,5).Text
      Case 36
         edtTest(3).Text = lblTest(3,6).Text
      Case 37
         edtTest(3).Text = lblTest(3,7).Text
      Case 45
         edtTest(4).Text = lblTest(4,5).Text
      Case 46
         edtTest(4).Text = lblTest(4,6).Text
      Case 47
         edtTest(4).Text = lblTest(4,7).Text
      Case Else
      Msgbox("Send.Tag = "&Send.Tag, "Probleme in lblTest_click")
      
      End Select
         
         
         
   
End Sub

Sub btnTest_Click
   Dim Send As Button
   
   Send=Sender
   Activity.Title="Button "&Send.Tag
End Sub

Sub pnlTest_Click
   Dim Send As Panel
   
   Send=Sender
   Activity.Title="Panel "&Send.Tag
End Sub

Sub edtTest_EnterPressed 'Berechnung der Ertgebnisse
   Dim Send As EditText
   
   Send=Sender
   Activity.Title="EditText "&Send.Tag&" = "&Send.Text
   

      
      
   'Hier komm ich nicht weiter
   'Ich muss ja prüfen welche Zahlen eingegeben wurden,
   'Es bibt aber jede Menge Varianten der Eingabe (a und b, a und c, a und Alpha, a und Beta, ....)
   'Dann ein Ergebnis ausrechen....
   'mit diesem Ergebniss das nächste, und dann wieder das nächste...
   'Solange bis alle Variablen berechnet sind
   'Dann müssen sie eingetragen werden
      
      
   If    edtTest(2).text <> 0 AND edtTest(3).Text <>0 Then Zahl(0,5) = edtTest(2).text*Sin(edtTest(3).text)
      '????
      
      'Variablen zum "Dreieck"
      
'   edtTest(0) = '"Kathete a"
'   edtTest(1) = '"Kathete b"
'   edtTest(2) = '"Hypotenuse c"
'   edtTest(3) = '"Winkel Alpha"
'   edtTest(4) = '"Winkel Beta"
'   edtTest(5) = '"Winkel Gamma"   

'   Zahl(0,5) =    '"c * sin(Alpha) = "
'   Zahl(0,6) =    '"b * tan(Alpha = "
'   Zahl(0,7) =    '"b / cot(Beta)="
'   
'   Zahl(1,5) =    '"c * cos(Alpha)="
'   Zahl(1,6) = 0   '"a * cot(Alpha)="
'   Zahl(1,7) = 0   '"a / tan(Alpha)=
'   
'   Zahl(2,5) = 0   '"a / sin(Alpha)="
'   Zahl(2,6) =    '"b / cos(Alpha)="
'   Zahl(2,7) = 0   '
'   
'   Zahl(3,5) = 0   '"invsin(a/c)="
'   Zahl(3,6) = 0   '"180-Beta-Gamma ="   
'   Zahl(3,7) = 0   '
'   
'   Zahl(4,5) = 0   '"180-Alpha-Gamma ="
'   Zahl(4,6) = 0   '"90-Alpha ="
'   Zahl(4,7) = 0   '   
'   
'   Zahl(5,5) = 0   '"180-Alpha-Beta ="
'   Zahl(5,6) = 0   '
'   Zahl(5,7) = 0   '
   


End Sub

Sub Dreieck   ' Labeltexte
   
   Text(0,1) = "Kathete a"
      Text(0,2) = "c * sin(Alpha) = "
      Text(0,3) = "b * tan(Alpha = "
      Text(0,4) = "b / cot(Beta) ="
      Zahl(0,5) = 0
      Zahl(0,6) = 0
      Zahl(0,7) = 0
   
   Text(1,1) = "Kathete b"
      Text(1,2) = "c * cos(Alpha) ="
      Text(1,3) = "a * cot(Alpha) ="
      Text(1,4) = "a / tan(Alpha) ="
      Zahl(1,5) = 0
      Zahl(1,6) = 0
      Zahl(1,7) = 0
   
   
   Text(2,1) = "Hypotenuse c"
      Text(2,2) = "a / sin(Alpha) ="
      Text(2,3) = "b / cos(Alpha) ="
      Text(2,4) = ""      
      Zahl(2,5) = 0
      Zahl(2,6) = 0
      Zahl(2,7) = 0   
   
   Text(3,1) = "Winkel Alpha"
      Text(3,2) = "invsin(a/c) ="
      Text(3,3) = "90-Beta ="
      Text(3,4) = "180-Beta-Gamma ="      
      Zahl(3,5) = 0
      Zahl(3,6) = 0
      Zahl(3,7) = 0   
   
   Text(4,1) = "Winkel Beta"
      Text(4,2) = "180-Alpha-Gamma ="
      Text(4,3) = "90-Alpha ="
      Text(4,4) = ""      
      Zahl(4,5) = 0
      Zahl(4,6) = 0
      Zahl(4,7) = 0   
   
   Text(5,1) = "Winkel Gamma"
      Text(5,2) = "180-Alpha-Beta ="
      Text(5,3) = ""
      Text(5,4) = ""
      Zahl(5,5) = 0
      Zahl(5,6) = 0
      Zahl(5,7) = 0   
   



End Sub
 

Attachments

  • edtTextRechner.zip
    8.6 KB · Views: 239
Last edited:

Watchkido1

Active Member
Licensed User
Longtime User
Hat jemand ne Idee wo man da suchen kann?

HI

Hat jemand ne Idee wo man da suchen kann?
Ich weiß nichtmal wie man sowas nennt.
Multi-Input-Auswahl-Eingabe-Berechnung?????

lg Frank
 
Top