.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

View list of previousYears and nextYears from current year dynamically

Posted By:satyapriyanayak       Posted Date: April 01, 2013    Points: 40    Category:    URL: http://www.dotnetspark.com  

View list of previousYears and nextYears from current year dynamically
 

Here we will see how to display a list of previous Years and next Years from current year dynamically into a combobox.

Public Class Form1

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If TextBox1.Text = "" Or TextBox2.Text = "" Then

            MsgBox("Please enter the previousYears & afterYears values")

        Else

            Dim previousYearsCount As Integer

            Dim afterYearsCount As Integer

            previousYearsCount = TextBox1.Text

            afterYearsCount = TextBox2.Text

            ComboBox1.Items.Clear()

            Dim currentYear As Integer

            currentYear = DateAndTime.Now.Year

            For addedYear As Integer = currentYear - previousYearsCount To currentYear + afterYearsCount

                ComboBox1.Items.Add(addedYear)

            Next

            TextBox1.Text = ""

            TextBox2.Text = ""

        End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ComboBox1.Text = "Please Select"

    End Sub

End Class



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend