Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 08-12-2012, 05:39 AM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default


Still not finding a lot of reading material on this subject as it pertains to powerpoint, snippits here and there....

Last edited by Jamtart; 08-12-2012 at 06:22 AM. Reason: error
Reply With Quote
  #17  
Old 08-12-2012, 06:20 AM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

THis is great, never thought about being able to enter the voltage value manually although I had done something like this in earlier projects, with limited success. This gives me ideas for variations and more projects, like, maybe making the resistor or resistors all manually enter rather than random varables, or for future projects like 3 resistors in parallel...

I am finding however after testing this that the value of current goes way off the mark after pressing enter a few times on the screen, thus other values go wonky too. The value of current should always be the value of total resistance, something goes wrong, sometimes it is bang on and other times it is not, looks like the decimal place becomes lost...
Looking at the script and not seeing why as the math looks good....

Last edited by Jamtart; 08-12-2012 at 06:50 AM. Reason: addition
Reply With Quote
  #18  
Old 08-12-2012, 12:50 PM
JohnWilson JohnWilson is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

"The value of current should always be the value of total resistance"

Shouldn't it be Voltage/Total resistance?

In the line current = CLng(Me.TextBox1.Value) / ResTotal you should probably replace CLng with CSng (though it still works OK here)

A single value will show up to 8 numbers (ie 0.1234567) My guess is your shape is too small to show them all?? Sometimes of course they are not all needed.

If need be you can use ROUND to set the max number of decimal places

ROUND(1.234567,3)= 1.235
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #19  
Old 08-12-2012, 01:25 PM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

I was going to ask if there was a way to have only up to four decimal places displayed.
However, I believe I found the issue(s). If you enter a value in the text box, say 240 volts and press enter, everything is fine. Take note that when you press enter you also change the resistance.
However if I enter a real small value for voltage, say 10 volts, then everthing goes funny. Such as the current displaying 1.980198E-02
then the voltages across the two resistors is wrong. I made the text boxes bigger so I could see the total number being generated. I would like to have only 3 or 4 numbers displayed.
The other item is that no matter what voltage you enter, if you click the resistor then it is using 120 V divided by the total resistance, not the value of voltage entered in the box. That is a function of Module 1.

Reply With Quote
  #20  
Old 08-13-2012, 05:37 AM
JohnWilson JohnWilson is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

This fixes the mistake and uses the new voltage.

When you use a very small voltage you may move out of the accuracy of a single floating point number (It displays as an exponential) I have changed all singles to double.

Important

Where I have used Slide2.Textbox1 note that youmust read the name of the slide object from the VB editor (make sure project explorer is visible)

Slide2 does not necessarily point at the second slide the name is independant of real slide number.
Attached Files
File Type: zip series circuit 3b.zip (295.8 KB, 7 views)
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #21  
Old 08-13-2012, 06:06 AM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

This seems to work perfectly, awesome, many thanks. I was going to put a caution note in the presentation not to go below a certain voltage.
So you can tell script to point to a different, i see in Module one:
current = Slide2.TextBox1 / ResTotal
That is very usefull to know.
I like the rounding too
Reply With Quote
  #22  
Old 08-13-2012, 07:24 AM
JohnWilson JohnWilson is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Just be sure you understang Slide objects. Microsoft made this very confusing and many people get caught out.

ActivX objects are contained in a "Slide Object" - This is NOT the slide. I don't know why they didn't call it the ActivXBox or similar but they didn't. Even worse it is always called Slidex (where x is a number.) x does NOT have to be the same as the slide number but the name will be unique. Moving or adding slides does not change the Slide Object name.

A slide can have only one "Slide Object" and you can use this to refer to ActivX objects as I did. Never assume the name of the Slide Object on slide 2 is Slide2!!!!
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #23  
Old 08-13-2012, 05:00 PM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

Hey John, I need your help with this again. After all the work you have done with both my projects I was able to create the attached. But now I am stuck.
Here is what I am trying to do now:
When a value is entered into "R1", I need text to appear in "resistor1" box that says "The Resistance is _____ Ohms"
When a value is entered into "R2", I need text to appear in "resistor2" box that says "The Resistance is _____ Ohms"
It would be great if The Value that appears in the "RT" box would generate a text into "Rounded Rectangle 31" (opps, forgot to rename) that says "The Total Resistance of the Circuit is _____ Ohms" then I could put RT off screen.
I got the Voltage one to work but when I try the ones above I get errors
I have a wish list too if I may. I would like to see minimum and maximum values set for some items, like the voltage set to a minimum of 10 and a max of 600
For the resistors a min of 10 and a max of 1000.
This is just a wish list.
Thanks for all your guidance on this project, I have learned so much. I am starting, I think, to make sense of the coding...
Attached Files
File Type: zip series circuit 4.zip (293.7 KB, 7 views)
Reply With Quote
  #24  
Old 08-14-2012, 12:39 AM
JohnWilson JohnWilson is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

I've added enough code to show you how to proceed I think.

Does your organisation send you to training conferences?

We will be working the Help Centre with Steve Rindsberg at "Presentation Summit" in Phoenix October. You would learn more in 4 days than you thought possible!!
Attached Files
File Type: zip series circuit 4.zip (293.2 KB, 8 views)
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #25  
Old 08-14-2012, 07:37 AM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

This is exactly what I needed John, I was able to follow your great work and complete the project, and now I can use this knowledge to start the next series.
I could ask about attending something like the conference, it would be unlikely as it does not deal with the program directly, so Im sort of on my own to create content like this. I would however have books paid for should I find some.
Is there a way to prevent users from altering this presentation without needing a password to open, but a password is needed to alter?
Reply With Quote
  #26  
Old 08-14-2012, 01:05 PM
JohnWilson JohnWilson is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

You can set a password to modify but it won't work in this case. It would stop your code modifying the slides.
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #27  
Old 08-14-2012, 01:28 PM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

Yea I found that out. And making it a read only does not accomplish this either. Maybe something just to protect the macros from snooping eyes? Better than nothing.
So Im moving on to part 2 of my project which is parallel circuits. So far so good except for one detail. With the series circuit the total resistance is it the addition of the resistances ie Me.RT.Text = Val(Me.R2) + Val(Me.R1)
However in a parallel circuit it is the inverse addition of the resistances, so my formula to the students would be 1/((1/resistor 1) + (1/resistor 2)). When I try to enter Me.RT.Text = 1/((1/Val(Me.R2)) + (1/Val(Me.R1)) I get an compile error. Any thoughts?
FYI, two 10 ohm resistors in parallel for example with give you a total resisatance of 5 ohms. If you have a reistor of 20 ohms and say one of 10 ohms in parrallel with each other you would have a total resistance of 6.6667 ohms...
Reply With Quote
  #28  
Old 08-14-2012, 06:02 PM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default Help!!!


This one has just gone side ways on me....
I cant get the Total Resistance to work as described earlier, and I cant get the current total to work.
Current total can be either:
Current= voltage/total resistance
OR
the sum of current1 and current2

Total resistance can be:
as I stated in my previous post
OR
voltage/current total

Ive been banging my head (my brain hurts now) for a good part of the day
Hope you can get me back on the right track...
Attached Files
File Type: zip parallel circuitx.zip (432.9 KB, 6 views)
Reply With Quote
  #29  
Old 08-14-2012, 08:26 PM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

I GOT IT!!!!!!
Let my brain unswell and low and behold I got it, works great I think. Once I put the finishing touches on I will upload a copy for you to review. Great job teach!!!
Reply With Quote
  #30  
Old 08-15-2012, 01:12 AM
JohnWilson JohnWilson is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

You CAN protect macros.

ALT f11 and then in Tools
VBA Project properties >> Protection TAB tick the obvios box and add a password
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to recap data of same numbers Jasa P Word VBA 0 06-28-2012 02:41 AM
Randomly generate numbers, Macro? Formatting changing randomly Franuzz Word 1 07-14-2011 04:12 PM
black text randomly changing to white when run macro G DeBree PowerPoint 0 03-16-2011 09:23 AM
Randomly delayed emails Colinest84 Outlook 1 01-14-2011 02:32 AM
Documents Randomly Corrupting the IT Guy Word 0 02-06-2009 09:11 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft