Solved date format on vba

Akai90

Member
Local time
Tomorrow, 05:57
Joined
Feb 8, 2022
Messages
67
hai

i have this code..
trktmtsementara = DateAdd("M", tempohsementara, tarikhsementara)

how can i set the date format to dd mmmm yyyy
i try to set via property sheet but not working

my full code
Private Sub trktmtsementara_GotFocus()
If tempohsementara = "6" Then
trktmtsementara = DateAdd("M", tempohsementara, tarikhsementara)
Else
If tempohsementara = "1" Then
trktmtsementara = "31 Disember " & Year(tarikhsementara) + IIf(tempohsementara > 1, tempohsementara, IIf(Year(tarikhsementara) > 1, 0, 1))
End If
End If
End Sub
 
Not sure why that would be?
1654162351264.png

1654162380096.png
 
on Design view of your Form, Click on tarikhsementara textbox.
on it's Property (Right Panel)->Format , put the format that you want (dd mmmm yyyy).
Code:
Private Sub trktmtsementara_GotFocus()
Dim n As Integer
n = Val(tempohsementara & "")
If tempohsementara = 6 Then
trktmtsementara = DateAdd("M", tempohsementara, tarikhsementara)
Else
If tempohsementara = 1 Then
trktmtsementara = DateSerial(Year(tarikhsementara) + IIf(tempohsementara > 1, tempohsementara, IIf(Year(tarikhsementara) > 1, 0, 1)), 12, 31)
End If
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom