473,408 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

I need to return 1 value based on an equation

I'm trying to do a form that returns the size of a circuit breaker when the kVA and voltage are entered, with a calculation behind the form working out the current.

Current = (kVA * 1000) / (Volts * 1.732)

However, I cannot find out how to do this, except by calling consecutive subs.

So, for instance, Current could be 17 Amps, 26 Amps, 45 Amps, anywhere up to 6300 Amps.

Circuit breakers are sized 10, 16, 20, 25, 32, 40, 50, 63, 100, 125, 160, 250, 400, 630...6300, so there are a lot of variables.

The only way i can get this to work is:

Expand|Select|Wrap|Line Numbers
  1. Call CBSize10
  2.  
  3. Private Sub CBSize10()
  4.     If [Current] <= 10 Then
  5.         Text39.Value = "10"
  6.     Else
  7.         Call CBSize16
  8.     End If
  9. End Sub
This would then need to go through 23 more subs if the current is large.

I've tried IIFs, but that's a no go. Any ideas?
Oct 18 '13 #1

✓ answered by Rabbit

Please use code tags when posting code or formatted data.

You can use a select case statement to choose the right breaker. For example:
Expand|Select|Wrap|Line Numbers
  1. Select Current
  2.    Case 0 To 10
  3.       BreakerSize = 10
  4.    Case 11 To 16
  5.       BreakerSize = 16
  6.    ......
  7.    Case Else
  8.       BreakerSize = -1
  9. End Select

5 1119
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

You can use a select case statement to choose the right breaker. For example:
Expand|Select|Wrap|Line Numbers
  1. Select Current
  2.    Case 0 To 10
  3.       BreakerSize = 10
  4.    Case 11 To 16
  5.       BreakerSize = 16
  6.    ......
  7.    Case Else
  8.       BreakerSize = -1
  9. End Select
Oct 18 '13 #2
NeoPa
32,556 Expert Mod 16PB
I would set up a table of the circuit-breakers; determine the current resulting from the calculation; Use a query (or DLookup()) to determine which record is returned that matches the maximum value where Current <= the value in the record.
Oct 19 '13 #3
Thank you for the responses. I'll give them a go over the next couple of days.

Sorry if I posted incorrectly. This is my first question, so bit a newb.
Oct 21 '13 #4
NeoPa
32,556 Expert Mod 16PB
Let us know how you get on.

PS. As long as you go forward and learn from any posted instructions, so not repeating past mistakes, we're more than happy. If we expected you to get it perfect first time we'd be dumb - and we try to avoid that ;-)
Oct 22 '13 #5
Okay, so I created a sub for the Case Select, and that works as I want it to. I can also see the benefits for a separate table and DLookup if I was entering the sizes from scratch. So thank you both. Happy chappy.
Nov 1 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

18
by: deanbrown3d | last post by:
I mean, is this correct? try { Screen->Cursor = crHourglass; Do something bad return false; else return true; }
8
by: Ravindranath Gummadidala | last post by:
Hi All: I am trying to understand the C function call mechanism. Please bear with me as I state what I know: "every invocation of a function causes a frame for that function to be pushed on...
8
by: Nick | last post by:
Hi, I'm trying to add some data on a company to an SQL server (which I can do), and want to return the FirmID (SQL identity) of the data that was just inserted so I can use it to redirect to...
4
by: Mark Kamoski | last post by:
Hi Everyone. What is the real difference between writing a Sub versus writing a Function with no return value? It seems to me that both of these would need to compile to the same IL, so it...
3
by: tshad | last post by:
I am trying to set up a class to handle my database accesses. I can't seem to figure out how to get the return value from my dataReader from these routines (most of which I got elsewhere). They...
7
by: Rudy | last post by:
Hello All! I have a value in a textbox(txbTableIDm.Text ) that I would like to use in a paremiter in a SP I wrote, and then have the select statement work off that parememter, retireive a...
7
by: Terry Olsen | last post by:
How do I get this to work? It always returns False, even though I can see "This is True!" in the debug window. Do I have to invoke functions differently than subs? Private Delegate Function...
173
by: Marty James | last post by:
Howdy, I was reflecting recently on malloc. Obviously, for tiny allocations like 20 bytes to strcpy a filename or something, there's no point putting in a check on the return value of malloc....
2
by: jbaranski | last post by:
I have spent several days attempting to accomplish a certain task but am truly no closer than I was near the beginning. i need to return a single value based on an employees payment option;...
1
by: BaseballGraphs | last post by:
Hello, I am requiring some assistance in creating a function that will be able to look up and return a value based on an ID using javascript. I am having a user click a checkbox and the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.