使用输入作为显示日期的基础 [英] Use input as basis of what date to display

查看:73
本文介绍了使用输入作为显示日期的基础的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种方法来使用用户窗体中的输入来确定输出上显示的日期。这是我的代码:

I need a way to use the input on a userform to determine the date that will be displayed on the output. Here's my code:

If StatusBox.Value <= "23:59" And ShiftCode.Value = "AP" Then
    Cells(emptyRow, 8).Value = ((Date - 1) + " " + StatusBox.Value + " " + "CEST")
Else
    Cells(emptyRow, 8).Value = (Date + " " + StatusBox.Value + " " + "CEST")
End If

基本上,当StatusBox.Value的输入小于或等于 11:59时,我需要将日期显示为 Date - 1 PM或23:59 StatusBox 字段中的输入将始终为12小时格式。

Basically I need the date to be displayed as Date - 1 when the input from StatusBox.Value is less than or equal to 11:59 PM or 23:59 the inputs on the StatusBox field will always be in the 12-Hour format.

推荐答案

此解决方案假定如下:


  • StatusBox.Value 是使用时间格式格式化的Excel序列号(不包括日期),因此 StatusBox.Value 是一个小数,其值范围从 0 (零) 0.99988426 ,代表从 0:00:00 (12:00:00 AM) 23:59:59 (11:59:59 PM)。因此,当这个序列号达到24小时变成 1 (一)。

  • StatusBox.Value is an Excel serial number formatted with a time format (no Date included) , as such StatusBox.Value is a decimal number with a value ranging from 0 (zero) to 0.99988426, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.). Therefore when this serial number reaches the 24 hours becomes 1 (one).

基于上述替换:

如果StatusBox.Value< =23:59

与此

如果StatusBox.Value< = 1 ...

但是如果 StatusBox.Value 包含一个日期值] 然后使用它作为替换行:

However if StatusBox.Value includes an [expected Date value] then use this as replacement line:

如果StatusBox.Value< = [预期的日期值] ...

这篇关于使用输入作为显示日期的基础的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆