Results 1 to 11 of 11

Thread: easy peasy

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    366

    easy peasy

    Basically i need a little bit of an equation that does the folowing:

    if number is 24 then add 13
    if number is 23 then add 14
    if number is 22 then add 15
    if number is 21 then add 16
    if number is 20 then add 17
    ...
    ...
    if number is 14 then add 23
    if number is 13 then add 24

    can anyone see a one line soution (or near as dammit) to this???

    thanks
    Attached Images Attached Images  
    Last edited by youngnoviceinneedofh; Feb 13th, 2008 at 11:37 AM.

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: easy peasy

    Code:
    If Number >= 13 AndAlso Number <= 24 Then Number = 37
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  3. #3
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: easy peasy

    Uhh.... 24 + X = 37... thus

    37 - 24 = X

    so

    37 - YourInputNumber = YourOutputNumber

  4. #4
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: easy peasy

    Quote Originally Posted by Jenner
    Uhh.... 24 + X = 37... thus

    37 - 24 = X

    so

    37 - YourInputNumber = YourOutputNumber
    Instead of doing all that math (which isn't much, I know) why not just check the value of 'Number' and if it's between the certain range, just make it 37

    If Number is between (or equal to) 13 and 24, then make it equal to 37
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  5. #5
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: easy peasy

    Quote Originally Posted by JuggaloBrotha
    Instead of doing all that math (which isn't much, I know) why not just check the value of 'Number' and if it's between the certain range, just make it 37

    If Number is between (or equal to) 13 and 24, then make it equal to 37
    I think by his question he's looking for what the number is needed to add to the first number. He has 24, puts it into the function, he's returned 13... that's how I read it. He listed it out as an example.

    Thus:

    Code:
    intNumberOut = 37 - intNumberIn

  6. #6
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: easy peasy

    Quote Originally Posted by Jenner
    I think by his question he's looking for what the number is needed to add to the first number. He has 24, puts it into the function, he's returned 13... that's how I read it. He listed it out as an example.

    Thus:

    Code:
    intNumberOut = 37 - intNumberIn
    In that case, yes a function would serve nicely. I read his post as:

    If Number = 24 then add 13, so Number = 37
    If Number = 23 then add 14, so Number = 37
    If Number = 22 then add 15, so Number = 37

    In which case, the end result is always Number = 37
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    366

    Re: easy peasy

    Sorry guys i dont mean add the number to itself i mean add the number to a different variable, but not so the total is always the same...

  8. #8
    Fanatic Member Clanguage's Avatar
    Join Date
    Jan 2008
    Location
    North Carolina
    Posts
    659

    Re: easy peasy

    Do you mean something like this?
    Code:
                Dim i, num1, num2 As Integer
                num1 = 24
                num2 = 13
                For i = 1 To 24
                    num1 -= 1
                    num2 += 1
                    Me.Text = num1 & " " & num2
                Next
    CLanguage;
    IF Post = HelpFull Then
    RateMe
    Else
    Say("Shut UP")
    End If
    DotNet rocks
    VB 6, VB.Net 2003, 2005, 2008, 2010, SQL 2005, WM 5.0,ahem ?OpenRoad?

  9. #9
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: easy peasy

    From your original post, it seems that the sum is always 37... Now that you've said the total is not always the same, I think you need to give us more details.

  10. #10
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: easy peasy

    Something like this:

    Code:
    OtherNumber += CalcNumber(Number)
    
    
    Private Function CalcNumber(Byval OriginalNumber As Integer) As Integer
      If OriginalNumber >= 13 AndAlso OriginalNumber <= 24 Then
        Return 37I - OriginalNumber
      Else
        Return 0I
      End If
    End Function
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  11. #11
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: easy peasy

    I'm totally and utterly confused at this point.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width