+ Reply to Thread
Results 1 to 11 of 11

Need Help With Some Basic Exercises in VBA

  1. #1
    Registered User
    Join Date
    06-11-2012
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Need Help With Some Basic Exercises in VBA

    Hello friends,I'm new at VBA programming and I have some exercises to be done.They are some basic and it is enough it just works.

    EXERCISE 1
    Write a program that asks the user to type all the integers between 8 and 23 (both included) using a for loop.
    EXERCISE 2
    Write a program that asks the user to type an integer N and computes the sum of the cubes from 53 to N3.
    EXERCISE 3
    Write a program that asks the user to type a positive integer. When the user types a negative value the program writes ERROR and asks for another value. When the user types 0, that means that the last value has been typed and the program must write the average of the positive integers. If the number of typed values is zero the program writes 'NO AVERAGE'.

    Thank you for your helps.
    Last edited by dirtysword; 06-11-2012 at 09:01 PM.

  2. #2
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Need Help With Some Basic Exercises in VBA

    Are you asking people to help you with your homework?

  3. #3
    Registered User
    Join Date
    06-11-2012
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Need Help With Some Basic Exercises in VBA

    It's not a homework.I told I'm new and i'm trying to learn,i don't force anybody .I just will be pleasure if somebody helps,if not it is not problem

  4. #4
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Need Help With Some Basic Exercises in VBA

    I don't know what you want with excecise 2, but here are the others.
    Code detecting a negative number.
    Please Login or Register  to view this content.
    Code for entering between 8 and 23.
    Please Login or Register  to view this content.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  5. #5
    Registered User
    Join Date
    06-11-2012
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Need Help With Some Basic Exercises in VBA

    In exercise 2 ,i'm trying to want an integer "N" from user. And the code computes the sum of the cube of 5 and 6,7,8.. to N. Thank you for the other ones mate

  6. #6
    Registered User
    Join Date
    06-11-2012
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Need Help With Some Basic Exercises in VBA

    By the way in the first one ,i'm trying to get all the numbers between 8 and 23.So the code shouldn't stop after entering one value.

  7. #7
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Need Help With Some Basic Exercises in VBA

    The first one does stop after entering a date between 8 and 23. Does it not for you?

  8. #8
    Registered User
    Join Date
    06-11-2012
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Need Help With Some Basic Exercises in VBA

    Quote Originally Posted by JapanDave View Post
    The first one does stop after entering a date between 8 and 23. Does it not for you?
    The user has to type all the numbers between 8 and 23,so the idea is something like that but there has to be something more,which i cannot do.

  9. #9
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Need Help With Some Basic Exercises in VBA

    Ok, I think I understand

    Ok , the cube root code.
    Please Login or Register  to view this content.

  10. #10
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Need Help With Some Basic Exercises in VBA

    For you last question.
    The below code enables you to select each number between 8 and 23, but it basically does nothing. All it has done is loaded then numbers into a string. What do you want done with the selected numbers?

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-11-2012
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Need Help With Some Basic Exercises in VBA

    That was exactly what i was trying to do mate , thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1