Check out our brand new Local Poker Communities! Get updates and interact with poker players in your area.
Visit the United States Poker Community | Visit the California Poker Community | Read more about the Launch of P5s Local

  1. Write a program in Visual Basic 6.0 according to the following specifications: <H3>Description</H3>
    • <LI>The program first asks the user for the month and year of his/her birth. <LI>Then the program validates the input if it's within the allowed range for months and years, and prompts the user in case of invalid input. <LI>If the input is correct the program then computes the age of the person and:
      • <LI>if it is over 65 it prints "You are a senior". <LI>if it is under 18 it prints "You are a kid" <LI>otherwise (if age is equal or between 18 and 65) it prints "You are an adult". </LI>
      <LI>In addition, if the birth month is the same as the current month, then the program also prints "Happy Birthday". </LI>
    <H3>Implementation</H3>Use two separate Text Boxes or Input Boxes for input and print on a Picture Box. Hints: For computing the age use code from Lecture 3, Problem 2. Then include If-Then or If-Then-Else blocks that check for the range of variable Years. Add also an If block that compares MOB with CurrentMonth and prints the birthday message. <H3>Documentation</H3>Run your program and make sure it works as described above. Then add your name in the beginning of the code as a comment (with Rem or '). Add also comments to explain how the code works. Note that comments and the way you format your program (follow the program format used in the book) will be graded too.

    Heres the codes we got to use from Lecture 3, problem 2. Can paypal some $ for help or have friend Xfer on stars :)

    <TT>Private Sub Form_Click()</TT>
    <TT> Dim MOB As Integer, YOB As Integer, Months As Integer, Years As Integer, MonthsLived As Integer</TT>
    <TT> Const CurrentMonth As Integer = 2</TT>
    <TT> Const CurrentYear As Integer = 2009</TT>
    <TT> MOB = InputBox("Enter Month of Birth")</TT>
    <TT> YOB = InputBox("Enter Year of Birth")</TT>
    <TT> MonthsLived = CurrentMonth + CurrentYear * 12 - MOB - YOB * 12</TT>
    <TT> Months = MonthsLived Mod 12 ' Remainder from integer division</TT>
    <TT> Years = MonthsLived \ 12 ' Integer division</TT>
    <TT> Cls</TT>
    <TT> Print " You are "; Years; "years and "; Months; " months old"</TT>
    <TT>End Sub</TT>
    Solution 2: Data validation (see Top 25 Most Dangerous Programming Errors)
    <TT>Private Sub Form_Click()</TT>
    <TT> Dim MOB As Integer, YOB As Integer, Months As Integer, Years As Integer, MonthsLived As Integer</TT>
    <TT> Const CurrentMonth As Integer = 2</TT>
    <TT> Const CurrentYear As Integer = 2009</TT>
    <TT> MOB = InputBox("Enter Month of Birth")</TT>
    <TT> YOB = InputBox("Enter Year of Birth")</TT>
    <TT> If YOB > 2009 Or YOB < 1900 Then ' Check if YOB is out of the interval [1900,2009]</TT>
    <TT> Print YOB, "Wrong year"</TT>
    <TT> Else</TT>
    <TT> MonthsLived = CurrentMonth + CurrentYear * 12 - MOB - YOB * 12</TT>
    <TT> Months = MonthsLived Mod 12 ' Remainder from integer division</TT>
    <TT> Years = MonthsLived \ 12 ' Integer division</TT>
    <TT> Cls</TT>
    <TT> Print " You are "; Years; "years and "; Months; " months old"</TT>
    <TT> End If</TT>
    <TT>End Sub</TT>
    Solution 3: More elaborated verification - ElseIf clause.
    <TT>Private Sub Form_Click()</TT>
    <TT> Dim MOB As Integer, YOB As Integer, Months As Integer, Years As Integer, MonthsLived As Integer</TT>
    <TT> Const CurrentMonth As Integer = 2</TT>
    <TT> Const CurrentYear As Integer = 2009</TT>
    <TT> MOB = InputBox("Enter Month of Birth")</TT>
    <TT> YOB = InputBox("Enter Year of Birth")</TT>
    <TT> If YOB > 2009 Or YOB < 1900 Then</TT>
    <TT> Print YOB, "Wrong year"</TT>
    <TT> ElseIf MOB > 12 Or MOB < 1 Then</TT>
    <TT> Print MOB, "Wrong month"</TT>
    <TT> Else</TT>
    <TT> MonthsLived = CurrentMonth + CurrentYear * 12 - MOB - YOB * 12</TT>
    <TT> Months = MonthsLived Mod 12 ' Remainder from integer division</TT>
    <TT> Years = MonthsLived \ 12 ' Integer division</TT>
    <TT> Form1.Cls</TT>
    <TT> Print " You are "; Years; "years and "; Months; " months old"</TT>
    <TT> End If</TT>
    <TT>End Sub</TT>
  2. C:/ reboot
  3. Did I miss the $50 on stars for homework help in the title?
  4. id prob try if it was for vb 2005
  5. Seriously, if you can't do this, then you need to drop out of programming class b/c this is SFsimple. I refuse to help you sir.
  6. The fact they still teach VB6 makes me want to puke
  7. i kinda agree with the poster above. are u struggling with this as in you dont know what to do? or are you just lazy and dont want to do it?

    if it is hte first one it is not a good sign for the rest of the semester, it only gets harder.

Similar Threads