davegri you are the best! Thanks to you all for your help! I'm going over all the examples to see how they work. Still work in progress for this form. I use of a Function is much clearer.
Thanks again!
davegri you are the best! Thanks to you all for your help! I'm going over all the examples to see how they work. Still work in progress for this form. I use of a Function is much clearer.
Thanks again!
THAT would have been useful info right in the beginning instead of writing code to just color boxes.By the way, I have to inform you that OP is trying to create a resistor calculator.
I guess you have to know your resistor stuff to know why there can be 4 or 5 bands and only 2 controls for choosing band color. That's not my forte for sure.
davegri you are the best! Thanks to you all for your help! I'm going over all the examples to see how they work. Still work in progress for this form. I use of a Function is much clearer.
Thanks again!
The one change I made iswOhms = (Band1 & Band2) * (10 ^ Band3) removed 19 lines of code! (took me awhile to get this right)
I should have thought of exponientation. Maybe negative exponents would also simplify the reduction to the string value in txtOhms.The one change I made is
wOhms = (Band1 & Band2) * (10 ^ Band3) removed 19 lines of code! (took me awhile to get this right)
Edit: Investigated and decided that dividing by positive exponents vs multiplying by negative exponents is just a choice to the same ends, saving no additional code lines beyond your nice change.
Last edited by davegri; 01-04-2019 at 01:55 PM. Reason: exponent choice
There could be a useful general function to divide values with 1000, as far as can, as shown below:
We can use this in an expresion like below:Code:Function DivValue(ByVal dblValue As Double, Optional strUnits As String = vbNullString) As String Dim i As Integer i = 1 While dblValue >= 1000 i = i + 1 dblValue = (dblValue / 1000) Wend DivValue = dblValue & Choose(i, "", "K", "M", "G", "T", "P", "E", "Z", "Y") & strUnits End Functionfor instance, in the davegri's example (Bands-davegri-v02.accdb) as Control Source of the text box "txtOhms".Code:=DivValue([txtwOhms];" Ohms")
I hope this helps.
I added my updated database to this forum. Thanks for all your help!
https://www.accessforums.net/showthread.php?t=75618