简体   繁体   English

日期格式正在切换月和日

[英]Date format is switching month and day

Could you please someone can help me on how to change the date formatting cause i use the following code and instead of today's date it gives me august date.请问有人可以帮助我如何更改日期格式,因为我使用以下代码,而不是今天的日期,它给了我八月的日期。 I mean it takes the date of my laptop (08-sep-2015) and it returns on the excel cell (09-Aug-2015).我的意思是它需要我的笔记本电脑的日期 (08-sep-2015) 并返回到 Excel 单元格 (09-Aug-2015)。

Private Sub UserForm_Initialize()
'testing variable
'Dim LValue As String

'LValue = Format(#4/17/2004#, "Long Date")
'close testing variable

Me.tbDate = Date


'fill combobox


For Each cell In [cartridges]
    Me.cmbCartridges.AddItem cell
Next cell

End Sub

The part that i exclude form the code is a test i made for a solution i found over the internet.我从代码中排除的部分是我为我在互联网上找到的解决方案所做的测试。

Also the text box that i want to present the date has the following code我想显示日期的文本框也有以下代码

ssheet.Cells(nr, 1) = CDate(Me.tbDate)

I found this and sorted my issue.我找到了这个并对我的问题进行了排序。 Now everything its working like a charm.现在一切都像魅力一样工作。

Me.tbDate = Format(Date, "dd/mm/yyyy")

I resolved my issue with this code.我用这段代码解决了我的问题。 I intentionally formated the cell the wrong way (excel default) and then formated it as I needed.我故意以错误的方式格式化单元格(excel 默认值),然后根据需要对其进行格式化。

For j = 0 To LISTBOXNAME.ListCount - 1
LISTBOXNAME.List(j) = Format(DateValue(LISTBOXNAME.List(j)), "m/d/yyyy")
LISTBOXNAME.List(j) = Format(DateValue(LISTBOXNAME.List(j)), "dd.mm.yyyy")
Next j

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM