View Single Post
 
Old 08-11-2012, 08:03 AM
JohnWilson JohnWilson is offline Windows 7 64bit Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,914
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Here's the basics

Code:
Sub UpdateRandomNumber()
Dim Randval As Long
Dim current As Single
Dim voltDrop1 As Single
Dim voltDrop2 As Single
Dim ResTotal As Single
Randval = Random(1000, 10)
ResTotal = Randval + 100
current = 120 / ResTotal
voltDrop1 = current * Randval
voltDrop2 = current * 100

MsgBox "Total resistance = " & CStr(ResTotal) & vbCrLf & _
"Current = " & CStr(current) & vbCrLf & _
"Volt Drop 1 = " & CStr(voltDrop1) & vbCrLf & _
"Volt Drop 2 = " & CStr(voltDrop2)
End Sub

Function Random(High As Long, Low As Long) As Long
Randomize
Random = Int((High - (Low - 1)) * Rnd) + Low
End Function
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote