If you trying to find the date just do Today.
Ex: Label1.text = today
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.
Last edited by Shark23; 03-16-2010 at 11:11 PM.
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.
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.
this should help
Working with dates and times in VB.NET
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]
Last edited by NextGen1; 03-16-2010 at 09:45 PM.
Shark23 (03-16-2010)
NextGen1 (03-17-2010)
Good to hear it was resolved
use the datatimepicker utility