I am having a problem with a program i am making with Visual Studio. It is a program designed to tell if the year that was entered into txtYear is a leap year. I need to display whether it is or isnt a leap year under the strLeap. However when I enter the code below using a call statement, it tells me "strLeap' is not a member of 'LeapYear.frmLeapYear' ". I have posted the full code. Our teacher gave it to us and we had to add in the last nested if statement with the "Private Sub CheckLeap". I know its most likely something small and easy but i need help..PLEASE!
Thanks!
[code]Option Strict On
Public Class frmLeapYear
Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
'* This module first checks to make sure a valid year has been entered.
'* it then converts the year to an integer, and
'* checks if it is a leap century (must be divisible by 400)
'* throws out all other centuries as non-leap years
'* checks remaining years (must be divisible by 4)
'* It then displays the results
Call CheckYear() '* check for valid year: > 0, integer
Dim intYear As Integer
Dim strLeap As String
strLeap = " Not replaced with message"
intYear = Convert.ToInt16(Me.txtYear.Text) '* convert valid year to integer
Call CheckLeap()
Me.lblLeap.Text = intYear & strLeap '* compose output message
Me.lblLeap.Visible = True '* display it
End Sub
Private Sub CheckYear()
Do While Not IsNumeric(Me.txtYear.Text) Or _
Int(Val(Me.txtYear.Text)) <> Val(Me.txtYear.Text) Or _
(Val(Me.txtYear.Text) <= 0)
'*** Year must be an integer and more than zero
If (Not IsNumeric(Me.txtYear.Text)) Then
Me.txtYear.Text = InputBox("Not a number. Retry: ", "Not a number")
ElseIf Int(Val(Me.txtYear.Text)) <> Val(Me.txtYear.Text) Then
Me.txtYear.Text = InputBox("Decimal places not permitted. Retry: ", "Not an integer")
ElseIf (Val(Me.txtYear.Text) <= 0) Then
Me.txtYear.Text = InputBox("Negative or zero year not permitted. Retry: ", "Negative or zero")
Else
MsgBox("Should not have gotten here. Year is " & Me.txtYear.Text)
Exit Sub
End If
Loop
End Sub
Private Sub CheckLeap()
Do While (Val(Me.txtYear.Text) Mod 400 = 0) Or _
(Val(Me.txtYear.Text) Mod 100 = 0) Or _
(Val(Me.txtYear.Text) Mod 4 = 0)
If (Val(Me.txtYear.Text) Mod 400 = 0) = True Then
Me.strLeap.Text = ("Is a Leap Year")
Else
If (Val(Me.txtYear.Text) Mod 100 = 0) = True Then
Me.strLeap.Text = ("Is Not a Leap Year")
Else
If (Val(Me.txtYear.Text) Mod 4 = 0) = True Then
Me.strLeap.Text = ("Is a Leap Year")
Else
Me.strLeap.Text = ("Is Not a Leap Year")
End If
End If
End If
Loop
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
'* clear the input, hide the output message again.
Me.txtYear.Clear()
Me.lblLeap.Visible = False
End Sub
Private Sub txtYear_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtYear.TextChanged
Me.lblLeap.Visible = False
End Sub
Private Sub frmLeapYear_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'* hide the output message at start
Me.lblLeap.Visible = False
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
'* Exit the program
Me.Close()
End Sub
End Class[/code]