我有一个用户表单,你可以从一个表格中获取日期。此表中的日期采用"dd/mm/yy“格式。当你得到日期时,它看起来是这样的:

我可以在这两个文本框中编写一个新的日期,并使用Modify按钮修改我的Table中的日期。
问题是,当新日期出现在表中时,它们会更改格式并转换为mm/dd/yy。
在将日期放入文本框和表格中时,我已经使用了format:
'putting date in Text Box:
FMDateEditor.tbFechaRecibida.Text = Format(MainCode.myRange.Cells(MainCode.EditIndexFechas, shMaster.ListObjects("MasterTable").ListColumns("Fecha recibida").index).Value, "dd/mm/yy")
'
'Puttting date in Table:
MainCode.myRange.Cells(MainCode.EditIndexFechas, shMaster.ListObjects("MasterTable").ListColumns("Fecha recibida").index).Value = Format(FMDateEditor.tbFechaRecibida.Text, "dd/mm/yy")但是这个问题仍然存在。
表格中的单元格格式为"dd/mm/yy“。
谢谢你的帮助
发布于 2021-01-06 12:42:36
Excel将日期存储为表示mm/dd/yyyy格式的数字,并以此格式执行所有计算。因此,在从变量赋值给变量时(或在计算中使用),应避免应用日期格式。
尝试:
FMDateEditor.tbFechaRecibida.Text = _
Format(MainCode.myRange.Cells(MainCode.EditIndexFechas, _
shMaster.ListObjects("MasterTable"). _
ListColumns("Fecha recibida").Index).Value, "dd/mm/yy") & ""https://stackoverflow.com/questions/65588339
复制相似问题