Results 1 to 4 of 4

Thread: Need Help With Random Number Placement

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    2

    Need Help With Random Number Placement

    I need to create a " Calculator" in VB and we cannot go into negative numbers for subtraction. So i need to have highest number first then lowest number 2nd. I have created a bit of code but it doesnt work to the best. I was wondering if you could help me and well, correct it for me.

    Some of the ovious stuff is their right, just figured id insert the general code so you get idea of what ive done. Thx

    Thx

    Code:
    Randomize
    num1 = Int(Rnd * 10) + 1
    
    num2 = Int(Rnd * 10) + 1
            
    LblNum1 = num1
    LblNum2 = num2
    
    If LblNum1 > LblNum2 Then
    LblNum1 = num1
    LblNum2 = num2
    Else
    LblNum1 = num2
    LblNum2 = num1
    
    
    End If

  2. #2
    Hyperactive Member jp26198926's Avatar
    Join Date
    Sep 2008
    Location
    General Santos City, Philippines
    Posts
    310

    Re: Need Help With Random Number Placement

    Code:
    Randomize
    num1 = Int(Rnd * 10) + 1
    
    num2 = Int(Rnd * 10) + 1
    
    if num1 > num2 then
    
       LblNum1 = num1
       LblNum2 = num2
    
    Else
    
       LblNum1 = num2
       LblNum2 = num1
    
    End if
    "More Heads are Better than One"

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2009
    Posts
    2

    Re: Need Help With Random Number Placement

    Thats great thank you, i know i had the general idea right, just didnt get it. Im doing a college IT course and we do some VB so i gotta design this as a project, not a pro or owt so yano =) Thx for help.
    Last edited by trippii; Apr 21st, 2009 at 12:17 PM. Reason: test somert

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Need Help With Random Number Placement

    Now that we've helped you, you can help us by marking the thread as resolved. If you have JavaScript enabled you can do that easily by pulling down the Thread Tools menu and selecting the Mark Thread Resolved item. Also if someone has been particularly helpful you have the ability to affect their forum "reputation" by rating their post. Only those ratings that you give after you have 20 posts will actually count, but in all cases the person you rate will see it and know that you appreciate their help.

    And BTW I don't know where in your program the randomize statement appears, but it should be someplace like Form_Load so that it is only done once.

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