1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Visual basic 6.0 small correction please help

Discussion in 'Software Development' started by enda101, Apr 23, 2010.

Thread Status:
Not open for further replies.
Advertisement
  1. enda101

    enda101 Thread Starter

    Joined:
    Feb 25, 2009
    Messages:
    28
    hey guys i got a huge problem. i have written code and i just cant get it to work so i said i would ask the pro's.
    so i have to write a code that counts how many years it takes for a person to become a millionaire. the person has to input their pay and there is a variable of being male or female. males get an increase of 8% a year and females get 5% (i didnt write it my female tutor did)
    i have a textbox to put in the amount of money you earn this year
    then a combo box with male or female.
    then a command button and i wrote the code for it. i will leave at the end.
    seriously i have been shifting through this code for 4 days now and i just dont see where i am going wrong. its probably the lack of sleep but i have deadlines so ya know. here is my code. any help would be reallly appreciated. all it normally needs is a fresh pair of eyes and i would be forever greatful.


    Private Sub Command1_Click()
    years = 0
    amount = Text1.Text
    gender = Combo1.Text
    If Text1.Text = "" Then
    MsgBox "fill in current pay"
    Elseif
    If gender = "Select One" Then
    MsgBox "select gender"
    Elseif
    If gender = "Male" Then
    Raise = 8 / 100
    Elseif
    If gender = "Female" Then
    Raise = 5 / 100
    Else
    MsgBox "Please enter valid criteria"


    End If


    While amount < 1000000
    amount = amount + (amount * Raise)
    years = years + 1
    Wend
    MsgBox ("You will become millionaire in " & years & " years")
    End Sub
     
  2. olliea95

    olliea95

    Joined:
    Nov 19, 2009
    Messages:
    84
    It's been ages since I've worked in VB 6 but I think I might be able to work this one out. What is the exact error you are getting at compile time?
     
  3. enda101

    enda101 Thread Starter

    Joined:
    Feb 25, 2009
    Messages:
    28
    oh yes i forgot to add. i did 2 tests. for the first one i used 100000 and i got a result of i think 30 years for male and 48 for female then i did a test for 10000 and got a result of 60 and 95.... like i dont even understand how it would have calculated that.
     
  4. olliea95

    olliea95

    Joined:
    Nov 19, 2009
    Messages:
    84
    Ok, I think its just a problem with the maths. Can't get my head around it though :S

    Right if you change:
    to:
    Now to try to explain it.
    will calculate the actual raise, so currently you are just taking the amount and adding the raise, and not adding the salary.

    Don't know if you followed that but its made sense to me. Hope it works.

    Edit:
    Come to think about it I think that might not work, give me 10 minutes just to think this through and I will post back.

    ------------------------------------------------------------------------------------------------------------------------------------------------------

    Edit 2: Looked over it all again, and I have renamed a couple of variables to stop me from getting confused, and I have added a totalAmount variable, because what you were doing is looping until the pay was equal to a million. So essentially it is acting as if you were banking the yearly pay plus the raise and the totalAmount variable is the bank balance. I haven't got VB6 on this computer so I can't test, sorry. Here is the complete program:

     
  5. enda101

    enda101 Thread Starter

    Joined:
    Feb 25, 2009
    Messages:
    28
    thanks Olive you where indeed right in the second one but i beat you to it :p. really sorry i didnt close it before now but i only just solved it this afternoon and did not think off it. thank you so very much for the help though. massively appreciated!
     
  6. olliea95

    olliea95

    Joined:
    Nov 19, 2009
    Messages:
    84
    Your welcome. Glad you managed to solve it.

    :)
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Solved Visual basic
  1. Bqwaszx
    Replies:
    1
    Views:
    410
  2. stevezal
    Replies:
    0
    Views:
    507
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/918713

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice