Question[Help]Now Date/Now Day

Posts 113 of 13 · Page 1 of 1
[Solved]Now Date/Now Day
Right now in VB I'm using a "DateInterval.Month" procedure and a "DateInterval.Day" procedure. Right now this is saying that it is February 4th. Is there a way to change that? I need the current date.
If you trying to find the date just do Today.
Ex: Label1.text = today
I need to check whether textbox1 = current month and textbox2 = current day.
if u want the time with the date it's:
Code:
now
I KNOW AMAZING RIGHT?
Uhhhh, no I don't need the time. Like I said before, I need to check whether or not TextBox1.Text = Current Month and TextBox2.Text = Current Day.
First

Namespace
[php]
Imports System.Globalization
Imports System.Threading
[/php]

Form Load Event or whatever triggers the event
I used a button

[php]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Info As CultureInfo = Thread.CurrentThread.CurrentCulture
Dim Curmonth As String = Info.DateTimeFormat.GetMonthName(DateTime.Now.Mont h)
Dim Curday As String = Info.DateTimeFormat.GetDayName(DateTime.Now.Day)
TextBox1.Text = Curmonth
TextBox2.Text = Curday
End sub
[/php]

My code will get the current month and current day and display them into separate text boxes.

Have fun




Still not working. Alright, so this program has 3 textboxes and a button. Textbox1 is for the month. Textbox2 is for the day. Textbox3 is for your name. I'm trying to input the month number(1-12) in textbox1 and the day number(1-31) in textbox2. If textbox1's text is the current month and textbox2's text is the current day, the messagebox displays a message. Right now I have:

Code:
        Dim Info As CultureInfo = Thread.CurrentThread.CurrentCulture
        Dim Curmonth As String = Info.DateTimeFormat.GetMonthName(DateTime.Now.Month)
        Dim Curday As String = Info.DateTimeFormat.GetDayName(DateTime.Now.Day)
        Dim strMonth As String
        Dim strDay As String
        Dim strName As String

        strName = txtName.Text
        strMonth = txtMonth.Text
        strDay = txtDay.Text

        If Curmonth = strMonth And Curday = strDay Then
            'Current date equals entered date
            MessageBox.Show("'Message here'")
        Else
            'Current date does not equal entered date
            MessageBox.Show("'Message here'")
        End If
    End Sub
Slight error in my code

I apologize

[php]
Dim Info As CultureInfo = Thread.CurrentThread.CurrentCulture
Dim Curmonth As String = Info.DateTimeFormat.GetMonthName(DateTime.Now.Mont h)
Dim Curday As String = Info.DateTimeFormat.GetDayName(DateTime.Today.DayO fWeek)
TextBox1.Text = Curmonth
TextBox2.Text = Curday
[/php]



This should work

Your code should be

[php]
Dim Info As CultureInfo = Thread.CurrentThread.CurrentCulture
Dim Curmonth As String = Info.DateTimeFormat.GetMonthName(DateTime.Now.Mont h)
Dim Curday As String = Info.DateTimeFormat.GetDayName(DateTime.Today.DayO fWeek)
Dim strMonth As String
Dim strDay As String
Dim strName As String

strName = TextBox1.Text
strMonth = TextBox2.Text
strDay = TextBox3.Text

If Curmonth = strMonth And Curday = strDay Then
'Current date equals entered date
MessageBox.Show("'Message here'")
Else
'Current date does not equal entered date
MessageBox.Show("'Message here'")
End If
End Sub
[/php]



Quote Originally Posted by NextGen1 View Post
Slight error in my code

I apologize

[php]
Dim Info As CultureInfo = Thread.CurrentThread.CurrentCulture
Dim Curmonth As String = Info.DateTimeFormat.GetMonthName(DateTime.Now.Mont h)
Dim Curday As String = Info.DateTimeFormat.GetDayName(DateTime.Today.DayO fWeek)
TextBox1.Text = Curmonth
TextBox2.Text = Curday
[/php]



This should work

Your code should be

[php]
Dim Info As CultureInfo = Thread.CurrentThread.CurrentCulture
Dim Curmonth As String = Info.DateTimeFormat.GetMonthName(DateTime.Now.Mont h)
Dim Curday As String = Info.DateTimeFormat.GetDayName(DateTime.Today.DayO fWeek)
Dim strMonth As String
Dim strDay As String
Dim strName As String

strName = TextBox1.Text
strMonth = TextBox2.Text
strDay = TextBox3.Text

If Curmonth = strMonth And Curday = strDay Then
'Current date equals entered date
MessageBox.Show("'Message here'")
Else
'Current date does not equal entered date
MessageBox.Show("'Message here'")
End If
End Sub
[/php]



Almost perfect. I need the day of the month(1-31) not the day of the week(Sunday-Saturday) but thanks a lot! This was really frustrating. Thanks!

EDIT: Got it working perfectly now!
Good to hear it was resolved
use the datatimepicker utility
Quote Originally Posted by Sixx93 View Post
use the datatimepicker utility
Issue already resolved, and using components in a situation where it is not needed is bad coding tactics
Posts 113 of 13 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?