Results 1 to 3 of 3

Thread: Life

  1. #1
    New Member
    Join Date
    Aug 12
    Posts
    1

    Cool Life

    Life, from a VBA perspective. Consider it open source
    (please excuse use of tabs)

    Code:
    function life(adult_age as integer, retirement_age as integer, _
    			  life_expectancy as integer) as integer
    
    	dim year as integer, luck as integer
    	dim mantra as string, brainwash as string
    
    	' childhood
    	mantra = "grow up"
    	for year = 0 to adult_age
    		brainwash = mantra
    	next year
    
    	' adulthood
    	mantra = "get a job"
    	for year = year to retirement_age
    		brainwash = mantra
    		luck = year + Int((7 * Rnd) - 3) ' randomly +/- 0 to 3
    		if luck >= retirement_age or luck >= life_expectancy then exit for
    	next year
    
    	' retirement
    	mantra = "retire"
    	for year = year to life_expectancy
    		brainwash = mantra
    		luck = year + Int((7 * Rnd) - 3) ' randomly +/- 0 to 3
    		if luck >= life_expectancy then exit for		
    	next year
    
    	life = 0
    end function

  2. #2
    Super Moderator koolsid's Avatar
    Join Date
    Feb 05
    Location
    Mumbai, India
    Posts
    11,406

    Re: Life

    Moved to Chit Chat from Visual Basic 6 and Earlier
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 12
    Posts
    5,471

    Re: Life

    Life? Don't talk to me about Life!

Posting Permissions

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