Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 25th, 2008, 11:09 AM
Hangman Hangman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 29 Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 h 56 m 6 sec
Reputation Power: 0
VBScript - How do you ADD two Variables multiplied ...

I don't think this title explains what I'm trying to ask here.
K, so, I was brainstorming the other night and came across a challenge (Well, at least for me it's a challenge).
Let's see if I can describe this.
Code:
Function GetNumber()
  Randomize
  GetNumber = Round(FormatNumber(Int((13 * Rnd) + 1)))
End Function
intVarA = GetNumber()
intVarB = GetNumber()
strVarA = " + " & intVarA
strAdditAll = Left(strVarA, intVarB)
MsgBox intVarA & " x " & intVarB & " = " & (intVarA * intVarB) & vbCrLf & _
"This means you add " & intVarA & ", " & intVarB & " times, like so, " & vbCrLf & _
intVarA & strAdditAll & " = " & (intVarA * intVarB)

As you can see, I'm not getting the same results.
How can I take these two variables and display them added together to get the same results as the multiplication equation ?? Another words, how can I add intVarA, intVarB times ??
Wow, I don't even understand what I'm asking
Thank you in advance for allowing me to put you through this mess. it's fun though isn't it ??

Reply With Quote
  #2  
Old September 26th, 2008, 07:25 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,254 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 25 m 34 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
How about this?
vb Code:
Original - vb Code
  1. Function GetNumber()
  2.   Randomize
  3.   GetNumber = Round(FormatNumber(Int((13 * Rnd) + 1)))
  4. End Function
  5. intVarA = GetNumber()
  6. intVarB = GetNumber()
  7. strVarA = " + " & intVarA
  8.  
  9. For i = 1 to intVarB
  10.     strAdditAll = strAdditAll & intVarA & " + "
  11. Next
  12. strAdditAll = Left(strAdditAll, Len(strAdditAll) - 3)
  13.  
  14. MsgBox intVarA & " x " & intVarB & " = " & (intVarA * intVarB) & vbCrLf & _
  15. "This means you add " & intVarA & ", " & intVarB & " times, like so, " & vbCrLf & _
  16. strAdditAll & " = " & Eval(strAdditAll)
To prove it works, I've used the Eval function to evaluate the constructed string as an expression.
__________________
Click the image if at any point you don't like my decision.

Scripting problems? Windows questions? Ask the Windows Guru!


Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > VBScript - How do you ADD two Variables multiplied ...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT