Android Question Stupid Question about dividing 2 values.

I know this question will seem stupid for all of you whom are familiar with the coding here. I used do a lot of calculators in VB. I just want to perform calculations on 2 numbers placed into edittext boxes named Voltage and Amperage then place the result in a edittext box named Resistance. I also want to trap errors by verifying that a number was placed in the Voltage and Amperage textboxs prior to running the calculations.

Any help would be sincerely appreciated.

Current Code gets errors on both the error traps and Resistance = Voltage / Amperage

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.

Private Button1 As Button
Dim Amperage As Double
Dim Resistance As Double
Dim Voltage As Double

End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("first")
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("first")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
'If Voltage_TextChanged = "" Then
'Msgbox("You must enter a voltage first","oops")
'End If
'If Amperage_TextChanged = "" Then
'Msgbox("You must enter an amperage first","oops")
'End If

Resistance = Voltage / Amperage
End Sub
Sub Voltage_TextChanged (Old As String, New As String)

End Sub
Sub Resistance_TextChanged (Old As String, New As String)

End Sub
Sub Amperage_TextChanged (Old As String, New As String)

End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Also thank you for the Sqrt info.
If you find an answer useful you can click on Like on that post to give some honor back to the one who answered
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Well thanks to all of your great assistance I was able to get the first of many calculators done. Believe when I say that I could not have done it without your help and support so thanks again.

Below is an image file of the app in the emulator.

Also thank you for the Sqrt info.


Bravo, but I now complicate your life :D:

R = V / A

but also:

V = R * A

and:

A = V / R

So you should change your calculator to obtain also these calculations ;)
 
Upvote 0
Well I just finished the basics and it is as follows:

V & R Known =
(V * V)/R = P
V/R = A

V & P Known =
(V * V)/P = R
P/V = A

V & A Known =
V * A = P
V/A = R

P & A Know =
P/A = V
P/(A * A) = R

P & R Known =
SQR(P * R) = V
SQR(P/R) = A

R & A Know =
R * A = V
R * (A * A) = P

Now all I have to do is create another 6 Modules for split phase with (power factor) PF and 2 for split phase.
Then I have to do it all over again with another 6 Modules to cover 3 phase with PF and 1.732 for 3 phase.

My next project will be for motors:
DC
1 phase
2 Phase
3 Phase
With PF and EFF(Efficiency)

The fun should really start when I get to the bearing database with all of the Values passed to the trigonometry functions. (This I have done in VB and Excel but the math in Basic4Android might prove challenging.)

Anyway, thanks for all of the help with what must seem like truly stupid questions to you. Unfortunately they were making me bang my head against my desk.
 
Upvote 0
Top