Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

writing a function in VB 6

Posted on 2004-11-21
8
Medium Priority
?
137 Views
Last Modified: 2010-05-02
I have to make a program that will use functions to solve this problem, but I can't figure it out...

here goes:

The resonant frequency of an inductor (L) and a capacitor (C), connected in parallel.

Where (f) is frequency in hertz, (L) is the inductance in Henrys, and C is the capacitance in Farads.  I have to develop an LCF calculator that uses this formula to calculate and display the value of a third component when the values of any two components are entered into the calculator.  This program has to contain three user-written functions, which I have, but the don't work. :(  The functions are (and I just need help with the logic, I believe I can do this):

1: return f when L and C are passed
2:  Return L when F and C are passed
3: Return C when F and L are passed.

F has to be displayed in Mhz
L has to be displayed in uH
C has to be displayed in pF

the conversion factors are:

1Hz = 10(-6)Mhz
1H = 10(6)uH
1F = 10(12)pF

I have three text boxes, and three cmd buttons on the page.

cmdFindC
cmdFindF
cmdFindL (the code that fires when this button is clicked is as follows)

Private Sub cmdFindL_Click()
      txtL.Text = FindL(txtF.text, txtC.text)
End Sub


Public Function FindL(byVal f as double, byVal C as Double) as Double
    ' code here is what I don't get. :(
End Function

------------------------------

I can not figure out this formula, please help :(  

Thanks in advance. :)
0
Comment
Question by:brooksreese
  • 6
  • 2
8 Comments
 
LVL 19

Expert Comment

by:Stephen Manderson
ID: 12640352
The formula for the physics equ. is it F=L x C just to confirm, I will make up a program that does it for you, give me 30 mins

Manderson
0
 
LVL 19

Accepted Solution

by:
Stephen Manderson earned 2000 total points
ID: 12640421
Hi there, you can download my example at

www.sdm-group.com/formula.zip

Hope this helps you

Manderson
0
 
LVL 19

Expert Comment

by:Stephen Manderson
ID: 12640426
The formula should be right, from what i remember from 1st year in uni.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:brooksreese
ID: 12640543
Thank you so much for your quick answer, are you sure it is as simple as multiplying and dividing the two numbers depending on what button is pushed?  My program is different, but the code you gave me let me understand more about what I should be doing. :)

Thank you so much for the help, but before I close this out can you help me with one function?

I have to display the results to an accuracy of three decimial places.  Should I do this before the function sends back the result, and how?

Thanks, brooks
0
 
LVL 19

Expert Comment

by:Stephen Manderson
ID: 12640615
I have updated it to round to 3 decimal places.
0
 
LVL 19

Expert Comment

by:Stephen Manderson
ID: 12640646
You can use the existing link to download the updated version.

Manderson
0
 
LVL 1

Author Comment

by:brooksreese
ID: 12640649
Wow MrManderson, that is a little too advanced for me - but I can definately learn from it. :)  Thank you very much for your help.  I am going to save your name for future reference, please feel free to do the same for me.

Brooks
0
 
LVL 19

Expert Comment

by:Stephen Manderson
ID: 12640667
Glad i could help.

Manderson
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question