Winter or Summertime Code ?!?

Skyfighter

Member
Joined
Oct 3, 2006
Messages
7
Programming Experience
Beginner
Hi all,

This is my first post here so soz when I'm fault.
But Does someone know pls if there is a code when you:

- Add a datum (ex. 02/01/06 ) in a textfield
-> If you click on a button
-> A messagebox appear and say if the time is summer or wintertime..

Many greets and thanks
 
theDate.IsDaylightSavingTime function returns true/false.
 
VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] d [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New [/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Date[/COLOR][/SIZE][SIZE=2](2006, 12, 15)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] tmp [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = IIf(d.IsDaylightSavingTime, [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"not "[/COLOR][/SIZE][SIZE=2])
tmp = [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2].Format([/SIZE][SIZE=2][COLOR=#800000]"{0} is {1}within daylight saving time."[/COLOR][/SIZE][SIZE=2], d.ToShortDateString, tmp)
MessageBox.Show(tmp)
[/SIZE]
 
VB.NET:
        Dim my_date As Date = textbox1.text

        Label1.Text = my_date.IsDaylightSavingTime

Can anybody say if Convert.ToDateTime should be used?

EDIT: Sorry didn't read the bit about needing a message box! doh! , also, JohnH - i never knew tghe IIf functiopn existed! :)
 
LeonR, you should use a DateTimePicker control or a MonthCalender control for the user to select a date. In cases where this is not possible you can have a look at the methods Date.TryParse, Date.TryParseExact, Date.Parse, Date.ParseExact. Convert.ToDateTime(String) is the same as Date.Parse method.
 
oke i've tried but it only gives 01/01/0001
So i want that from any date that has filt in in the textbox (12/12/2006 or 20/12/2006 or 31/05/2006 or etc.........) a messagebox appear after clicking the button and says in what time the date is (winter or summer time)
 
JohnH has written the example?

Just modify it to suit.


Heres my code

VB.NET:
  Dim my_date As Date = Date.Parse(TextBox1.Text)
        Dim gmt_msg As String = Nothing

        If my_date.IsDaylightSavingTime = True Then
            gmt_msg = "summer time"
        Else
            gmt_msg = "winter time"
        End If

        MsgBox(TextBox1.Text & " is " & gmt_msg, MsgBoxStyle.Information, "woop woop!")


Im not fully understanding the problem? Or did you miss JohnH's post?
 
Last edited:
Back
Top