3 Replies - 160 Views - Last Post: 30 July 2012 - 11:32 AM Rate Topic: -----

#1 Raminator  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 205
  • Joined: 16-July 12

Getting the day of the month

Posted 30 July 2012 - 10:58 AM

Im making a program that calculates for how long have you been awake and i just added a combobox for you to select the day you woke up,the problem is i want the combobox to be selected at the day it is whn the person runs the program but im having some difficulty doing this.
Heres the code for now.
Public Class Form1
    Dim wokeup As DateTime
    Dim awake As DateTime
    Dim CurrentTime As DateTime
    Dim am As String
    Dim pm As String
    Dim lop As Integer
    Dim today As Date
    Dim monthday As Date
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim lop As Integer
        ComboBox1.Items.Add("AM")
        ComboBox1.Items.Add("PM")
        ComboBox1.SelectedItem = "AM"
        ' ComboBox2.SelectedItem =
        today = (DateAndTime.Today)
        'monthday =
        For lop = 1 To 31
            ComboBox2.Items.Add(lop)
        Next lop
    End Sub

    Private Sub NumericUpDown1_ValueChanged(sender As System.Object, e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        wokeup = TextBox1.Text + ComboBox1.SelectedItem
        CurrentTime = DateTime.Now

        'Label2.Text = (CurrentTime.Subtract(wokeup)).ToString
        Label2.Text = today

    End Sub
End Class



Is This A Good Question/Topic? 0
  • +

Replies To: Getting the day of the month

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 6457
  • View blog
  • Posts: 23,488
  • Joined: 12-June 08

Re: Getting the day of the month

Posted 30 July 2012 - 11:16 AM

You mean the day property of any date time?

http://msdn.microsof...tetime.day.aspx
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3872
  • View blog
  • Posts: 11,405
  • Joined: 18-April 07

Re: Getting the day of the month

Posted 30 July 2012 - 11:17 AM

You can try, after your for loop, the following...

ComboBox2.SelectedItem = DateTime.Now.Day;



See if that works for you. :)
Was This Post Helpful? 1
  • +
  • -

#4 Raminator  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 205
  • Joined: 16-July 12

Re: Getting the day of the month

Posted 30 July 2012 - 11:32 AM

View PostMartyr2, on 30 July 2012 - 11:17 AM, said:

You can try, after your for loop, the following...

ComboBox2.SelectedItem = DateTime.Now.Day;



See if that works for you. :)

Thank you that worked
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1