norris1023
norris1023

Reputation: 633

Can someone tell me what i might be doing wrong

Ok I am edited this. This is what i have so far. Option Strict On Option Explicit On

Module Module1

Sub Main()
    Dim numberofdays As Integer
    Dim month As Integer
    Dim year As Integer

    Select Case month
        Case 4, 6, 9, 11
            numberofdays = 30
        Case 1, 3, 5, 7, 8, 10, 12
            numberofdays = 31
        Case 2
            Select Case year
                Case 2004, 2008, 2012, 2016
                    numberofdays = 29
                Case Else
                    numberofdays = 28
            End Select
    End Select
    Console.WriteLine("Please enter your month")
    Console.ReadLine()
End Sub

End Module Now i get it to come up but when you type in 3 nothing comes up i have tried putting in the writeline( this month has 31 days in it) but still nothing can someone tell me what i am doing wrong. I am working with select case. I am still new to this so I am not that far in advance thanks.

Upvotes: 0

Views: 102

Answers (3)

Matt
Matt

Reputation: 1038

numberofdays(31) should be numberofdays = 31 and same for when it is 30 days

Upvotes: 0

Polyfun
Polyfun

Reputation: 9639

To add to what everyone else has said, you need to fix the following line too:

Select Case year()

This should be

Select Case year

(no brackets).

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1500595

You're trying to call numberofdays as if it were a method, like this:

numberofdays(31)

I suspect you meant to assign the value to the variable, like this:

numberofdays = 31

You're also trying to use month and year without giving them values first. Which month are you interested in, and which year? If you're interested in the current month and year, you might want to use:

Dim now As DateTime = DateTime.Now
Dim month as Integer = now.Month
Dim year as Integer = now.Year

Note that if this isn't just to experiment with the language, you should look at DateTime.DaysInMonth.

Upvotes: 4

Related Questions