Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 4th, 2008, 6:21 PM   #1
Skezid
Code Poet
 
Skezid's Avatar
 
Join Date: Feb 2008
Location: Sydney, Nova Scotia (Canada)
Posts: 5
Rep Power: 0 Skezid is on a distinguished road
Critique (Lay it on me)

Hey, upon reading this thread, I was tempted to test my skills and create a program that would duplicate the idea of taking user input (birth date) and determining what Zodiac sign that date would output. Now, one of my biggest flaws is in the planning department. I've never had anyone ever critique my coding methods or skills, so I don't know if I'm approaching problems the "correct" way or not.

I would define the "correct" way as the way in which uses the best methods to solve the problem as easily as possible, and as efficiently as possible without useless unneeded code. Expansion is also nice, but I'm not quite at that point yet. =p

Since I'm best with VB6, I made my application with it.

So beat and batter my logic about, and post if you have any better ways of doing the same thing. Because as I've been taught in college, everyone approaches a problem differently.

Tips are also appreciated.


Those who don't want to download anything, here's all of the code

Dim DaysInMonth(0 To 11) As Integer     'array to hold the number of days in each month



Private Sub cmbMonth_Click()

    'Get the item number that was selected
    Dim MonthItemNum As Integer
    MonthItemNum = cmbMonth.ListIndex
    
    'Get the number of items in the cmbDays combo box
    'To determine how many days we have to add or remove
    'Depending on the month selected
    Dim TotalDays As Integer
    Dim NumOfDays As Integer
    Dim Difference As Integer
        
    TotalDays = cmbDay.ListCount        'total days in the list currently
    NumOfDays = DaysInMonth(MonthItemNum)       'total amount of days in the month selected
    
    'Find the difference
    Difference = NumOfDays - TotalDays
    
    
    
    
    ' If the difference is greater than 0, then add days
    If Difference > 0 Then
           
        For i = 1 To Difference
            cmbDay.AddItem (TotalDays + i)
        Next i
    
    ' If the difference is less than 0, then subtract days
    ElseIf Difference < 0 Then
        
        Difference = Difference * -1     'Make it positive
        For i = 1 To Difference
            cmbDay.RemoveItem (TotalDays - i)
        Next i
    End If
    
    
    
    
    
End Sub

Private Sub cmdGetSign_Click()
    'Determine the Zodiac sign by the values of cmbDay and cmbMonth
    Dim Day As Integer
    Dim Zodiac As String
    
    Day = cmbDay.Text
        
    Select Case cmbMonth.ListIndex
        'January
        Case 0:
           'CAPRICORN
            If Day < 20 Then
                Zodiac = "Capricorn"
            
            'AQUARIUS
            Else
                Zodiac = "Aquarius"
            End If
                
            
            
        'February
        Case 1:
            'AQUARIUS
            If Day < 20 Then
                Zodiac = "Aquarius"
            'PISCES
            Else
                Zodiac = "Pisces"
            End If
                
        

        'March
        Case 2:
            'PISCES
            If Day <= 20 Then
                Zodiac = "Pisces"
            
            'ARIES
            Else
                Zodiac = "Aries"
            End If
            
        

        'April
        Case 3:
            'ARIES
            If Day <= 20 Then
                Zodiac = "Aries"
            
            'TAURUS
            Else
                Zodiac = "Taurus"
            End If
    
    
    
        'May
        Case 4:
            'TAURUS
            If Day <= 21 Then
                Zodiac = "Taurus"
                
            'GEMINI
            Else
                Zodiac = "Gemini"
            End If
        

    
        'June
        Case 5:
            'GEMINI
            If Day <= 22 Then
                Zodiac = "Gemini"
            
            'CANCER
            Else
                Zodiac = "Cancer"
            End If
        

    
        'July
        Case 6:
            'CANCER
            If Day <= 23 Then
                Zodiac = "Cancer"
                
            'LEO
            Else
                Zodiac = "Leo"
            End If
    
    
    
        'August
        Case 7:
            'LEO
            If Day <= 23 Then
                Zodiac = "Leo"
            
            'VIRGO
            Else
                Zodiac = "Virgo"
            End If
            
        
   
        'September
        Case 8:
            'VIRGO
            If Day <= 23 Then
                Zodiac = "Virgo"
                
            'LIBRA
            Else
                Zodiac = "Libra"
            End If
        
        
        'October
        Case 9:
            'LIBRA
            If Day <= 23 Then
                Zodiac = "Libra"
            
            'SCORPIO
            Else
                Zodiac = "Scorpio"
            End If
        
        
        'November
        Case 10:
            'SCORPIO
            If Day <= 22 Then
                Zodiac = "Scorpio"
            
            'SAGITTARIUS
            Else
                Zodiac = "Sagittarius"
            End If
            
        
        
        'December
        Case 11:
            'SAGITTARIUS
            If Day <= 22 Then
                Zodiac = "Sagittarius"
                
            'CAPRICORN
            Else
                Zodiac = "Capricorn"
            End If
        
        
    End Select
    
    
    lblSign.Caption = "Your sign is: " & Zodiac
    
End Sub



Private Sub Form_Load()

    'Fill in the cmbDay list box with 31 days (default)
    
    For i = 1 To 31
        cmbDay.AddItem (i)
    Next i
    
    cmbDay.ListIndex = 0        'sets the list to the first item
    
    'Fill in the cmbMonth list box with the months
    '(January by default)
    cmbMonth.AddItem ("January")
    cmbMonth.AddItem ("February")
    cmbMonth.AddItem ("March")
    cmbMonth.AddItem ("April")
    cmbMonth.AddItem ("May")
    cmbMonth.AddItem ("June")
    cmbMonth.AddItem ("July")
    cmbMonth.AddItem ("August")
    cmbMonth.AddItem ("September")
    cmbMonth.AddItem ("October")
    cmbMonth.AddItem ("November")
    cmbMonth.AddItem ("December")
    
    
    'Fill the DaysInMonth array
    DaysInMonth(0) = 31             'January
    DaysInMonth(1) = 29             'Feburary (leap year)
    DaysInMonth(2) = 31             'March
    DaysInMonth(3) = 30             'April
    DaysInMonth(4) = 31             'May
    DaysInMonth(5) = 30             'June
    DaysInMonth(6) = 31             'July
    DaysInMonth(7) = 31             'August
    DaysInMonth(8) = 30             'September
    DaysInMonth(9) = 31             'October
    DaysInMonth(10) = 30            'November
    DaysInMonth(11) = 31            'December
    
    
    
    
    
    
    cmbMonth.ListIndex = 0      ' sets the list to the first item
    
    
    
End Sub
Attached Files
File Type: zip Zodiac.zip (2.5 KB, 1 views)
Skezid is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Critique of Policy Based Factory Pattern: Game_Ender C++ 0 Oct 1st, 2007 10:13 PM
Critique my exercise somehollis Python 8 Jun 12th, 2006 5:18 PM
Code Critique darthsabbath C 5 Jun 3rd, 2006 3:16 AM
Client code critique jayme C++ 0 Apr 8th, 2006 5:54 PM
Need Critique and Members wdz PHP 33 Aug 2nd, 2005 8:55 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC