DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2006
    Posts
    10

    Need help with a Calculation

    Well im making a calculator but i want to put this into my calculator
    1=0.25
    2or3=0.50
    4or5=0.75
    6or7=1.00
    8or9=1.25
    10o11=1.50
    12or13=1.75
    14or15=2.00
    16or17=2.25
    18or19=2.50
    20or21=2.75
    22or23=3.00
    24or25=3.25
    26or27=3.50

    and all the way up to
    98or99=12.25

    Hope you understand and would like this code alot to finish my calculator

  2. #2
    Join Date
    Dec 2005
    Location
    New Jersey
    Posts
    290
    Not sure i understand... so you want when you input 26 or 27 to get 3.5?

    Here's some pseudocode:
    Code:
    if number is odd
        result = number - 1
    end if
    result = (result / 2.0 * .25) + .25;

  3. #3
    Join Date
    Jan 2006
    Posts
    10
    ill try this and reply i

  4. #4
    Join Date
    Jan 2006
    Posts
    10
    this is what i got
    Code:
    Option Explicit
    
    Private Sub Command1_click()
        Dim firstNumber As Integer
        Dim secondNumber As Integer
        Dim thirdNumber As Integer
        Dim forthNumber As Integer
        Dim fithNumber As Integer
        Dim Result As Integer
        firstNumber = Attack.Text * 0.325
        secondNumber = Strenght.Text * 0.325
        thirdNumber = Deffence.Text / 4
        forthNumber = Hits.Text / 4
        fithNumber = Prayer.Text * 0.25
        Result = firstNumber + secondNumber + thirdNumber + forthNumber + fithNumber
        Text1.Text = Result
    End Sub
    and what i want is instead of prayer.text *0.25 i want it to go up and extra 0.25 every even number and still be same for lower odd number than it

  5. #5
    Join Date
    Jan 2006
    Posts
    10
    i think you answer would work but i dont know where to put it into my code could you posibly put it in for me, thanks for helping

  6. #6
    Join Date
    Dec 2005
    Location
    New Jersey
    Posts
    290
    I probably would help you there, but I really only know Java and C/C++

  7. #7
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Try this:

    fifthNumber = ((Prayer.Text \ 2) + 1) * 0.25
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  8. #8
    Join Date
    Jan 2006
    Posts
    10
    its alittle off,

    Is thier a calculation i can use so that prayer.text would multiply only on even numbers and stay same as previous even number when it is odd? i realy need this its a vital calculation

  9. #9
    Join Date
    Jan 2006
    Posts
    10
    what i want is,

    if Prayer.text = odd then - 1 then *0.25
    If Prayer.text = Even *0.25

    I want a code that would do that i know what i typed probly isnt even code but it says what i want

  10. #10
    Join Date
    Jan 2006
    Posts
    10
    ive fixed this problem but now i got anoughter
    VB seems to be rounding up or down my numbers is thier neway of stoping this?

  11. #11
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Please post your code.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  12. #12
    Join Date
    Jan 2006
    Posts
    10
    i worked it out i had
    Code:
    As FirstNumber interget
    But i changed that and now it works thank you for all your help

Similar Threads

  1. Calculation - Optimization
    By sakis in forum VB Classic
    Replies: 2
    Last Post: 09-27-2005, 11:44 AM
  2. Replies: 0
    Last Post: 09-19-2005, 07:21 AM
  3. Replies: 0
    Last Post: 09-19-2005, 06:07 AM
  4. Javascript calculation query...
    By Scott D. in forum Architecture and Design
    Replies: 0
    Last Post: 05-23-2002, 02:04 PM
  5. Diameter calculation
    By Tom in forum Database
    Replies: 2
    Last Post: 11-28-2001, 11:44 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links