Using The Date Class

kkocak

Registered User.
Local time
Today, 16:04
Joined
Jan 12, 2007
Messages
13
hey guys, i got a program that has a label with the Date.Now method to display the computer date and time.....i also have about 5 drop-down boxes for which i want to return segments of the date....for example...if the date read-out is now.....2/6/2007 7:10:46 PM.........i need one one of the combo boxes to display..."February"


I am not familiar with visual basic, however, is it possible to return the date in the combo box, something like. ComboBox1.Text = (##)...then run a 'Case' loop for the month (i.e. Case 1 = "January" Case 2 = "Feburary" Case 3 = "March"


any ideas????
 
Look in the Help for the DatePart function. It can handle all of your needs.
 
Good post.....however, i want the month to return a String, not a integer....is the only way do to something like this

ComboBox1.Text = DateInterval.Month

If (ComboBox1.Text = 1) Then
ComboBox1.Text = "January"

ElseIf (ComboBox1.Text = 2) Then
ComboBox1.Text = "February"

ElseIf (ComboBox1.Text = 3) Then
ComboBox1.Text = "March"
..................
 
look up Format() then and that will turn it into text

Peter
 
As Peter said, all you have to do is use the Format function

The format function is well documented in the Access VB help file.
 
Yea ok, i suck...........anyway i am "designing" (more like cant figure it out) a countdown program..... not working
here its what i got so far. I load up my first combobox with the months (in strings)...then load up the year 2000-2099....then i try to use if...then statements to load up the days combox...and it aint workin...

Public Class Form1

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


Dim Year As Integer
For Year = 2000 To 2099
ComboBox3.Items.Add(Year)
Next Year

Label1.Text = (Date.Now)

ComboBox1.Items.Add("January")
ComboBox1.Items.Add("February")
ComboBox1.Items.Add("March")
ComboBox1.Items.Add("April")
ComboBox1.Items.Add("May")
ComboBox1.Items.Add("June")
ComboBox1.Items.Add("July")
ComboBox1.Items.Add("August")
ComboBox1.Items.Add("September")
ComboBox1.Items.Add("October")
ComboBox1.Items.Add("November")
ComboBox1.Items.Add("December")

If (ComboBox1.Text = "February") Then

Dim Cal1 As Integer
For Cal1 = 1 To 28
ComboBox2.Items.Add(Cal1)
Next Cal1
ElseIf (ComboBox1.Text = "February") Then

Dim Day As Integer
For Day = 1 To 34
ComboBox2.Items.Add(Day)
Next Day
End If
 
kkocak said:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
I can see that you are using .NET for this (so not really VBA, which this particular forum you posted in is for), so you might want to post this question in the VB.NET forum that is listed a bit further on down the list. The controls are different in Access and VBA than in VB/VB.NET so I can't give much help in that as I'm not very fluent in .NET yet.
 

Users who are viewing this thread

Back
Top Bottom