PDA

View Full Version : Solved: Date split



Alvinkiang
07-20-2006, 07:59 PM
Hey people, Any idea how to do a Date split of a textbox value. i tried this way below but it doesnt seems to display the mm. basically, i have created a 12 sheet(from Jan- Dec) and i want the date from the textbox to split into mm|dd|yyyy. it will first get the mm and it will go into the sheet that the mm falls into. eg, if the mm is 1, den it will go to my Jan sheet. if the mm is 2, then it will go to my Feb sheet.

Dim mySchedule As Variant

mySchedule = txtSchedule.Value
mySchedule = Split("mm|dd|yyyy", "|")

MsgBox (mm)


could anyone please help mi? thanks

Killian
07-21-2006, 01:38 AM
The Split function returns an array, so:
mySchedule = Split("mm|dd|yyyy", "|")

results in:
mySchedule(0) will be "mm"
mySchedule(1) will be "dd"
mySchedule(2) will be "yyyy"


I think you might want to look at the DatePart function that returns the specified part of a given dateConst d As Date = "11/08/2006"

Dim strTemp As String

strTemp = "Date: " & d & vbLf & _
"Day: " & DatePart("d", d) & vbLf & _
"Month: " & DatePart("m", d) & vbLf & _
"Year: " & DatePart("yyyy", d)

MsgBox strTemp

fanpages
07-21-2006, 03:33 AM
Why not try this instead?

If IsDate(txtSchedule.Value) Then
Worksheets(Format$(txtSchedule.Value, "mmm")).Activate
End If


Or if pipe characters are already in your txtSchedule value...

If IsDate(Replace(txtSchedule.Value, "|", "/")) Then
Worksheets(Format$(Replace(txtSchedule.Value, "|", "/"), "mmm")).Activate
End If


BFN,

fp.

Alvinkiang
07-23-2006, 05:45 PM
sorry for late reply... thxs ppls=D cheers~