Questions

Excel Visual Basic

+
0 Votes
Locked

Excel Visual Basic

scouser42
Hello everyone

I,m in a bit of a pickle and wondering could anyone help please. I have been asked to create a visual basic programme in excel and as I have never used it before I'm struggling. I thought with the ever mighty internet I may be able to sort something out but nothing so far.
I need to come up with something based on Ohms law i.e input the voltage and current and the programme then tells you the resistance and the wattage of the item.
Every thing I've tried is useless. Could anybody point me in the right direction with this. Any help would be greatly appreciated.
Thanks in advance
+
0 Votes
ComputerCookie
Collapse -

post your code first.

A good programmer could look at your code and easily modify it.

A good programmer could look at your question and he doen't know Ohm's Law!!!!

Your problem slacko.

+
0 Votes
jimmy-jam
Collapse -

E=I/R

+
0 Votes
jimmy-jam
Collapse -

Or can you just use formula's in Excel?

+
0 Votes
scouser42
Collapse -

Hi Jimmy Jam

Yes it has to be visual basic and thanks for replying

+
0 Votes
jimmy-jam
Collapse -

Open Excel - hit Alt + F11
Visual Basic Editor comes up.
Right click on sheet1 and insert user form.
Drag two textbox's and a command button on to the form.
Double click on the command button and the script editor will pop up.
Insert the following code.

Voltage = TextBox1.Text
Current = TextBox2.Text
Resistance = Current / Voltage
Power = Voltage * Current
MsgBox ("Resistance = " & Resistance & vbCr & "Power = " & Power)

Save it. Push the green triangle at the top for the visual basic editor to trial run the form. Input your numbers and you should get a pop up with the values you are looking for.

Note: The above code will only come out right if you make textbox1 volts and textbox2 current. Also you will need to play getting it to launch when you open the workbook. There are some setting which I am not familiar with to get it to launch. If you continue to have problems post back or PM me and I'll see what I can come up with. Good luck.

+
0 Votes
IC-IT
Collapse -

your (school?) project.

http://www.the12volt.com/ohm/ohmslaw.asp

There are also Ohms caculator programs that could help.
C Code example;

http://www.c.happycodings.com/code_snippets/code46.html

If you are doing a Google Search, you might run across this (don't plaguarize though);
http://www.p-m-services.co.uk/ohms_law_calc.htm

+
0 Votes
scouser42
Collapse -

Thank you both so much. Jimmy Jam I'll give it a try and let you know although it will probably be tomorrow that I will be in touch.
Best regards