文本框格式“hh”不显示领先零 [英] Textbox Format "hh" Not Displaying Leading Zero

查看:114
本文介绍了文本框格式“hh”不显示领先零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何修正方法可以更正报告或表单文本框中前导零的丢弃,其控件是日期/时间值,其显示格式包括 "hh"? 我知道解决方法是使用Format()
将日期/时间转换为 字符串,但为什么要有解决方法?

Will there ever be a fix to correct the dropping of the leading zero in a report or form textbox whose control is a Date/Time value and whose display format includes "hh"?  I know the workaround is to use Format() to convert the Date/Time to a String, but why should there be any workaround?

我被困在使用Access 2010年上班。

I am stuck using Access 2010 at work.

谢谢

Phil。

推荐答案

通常,显示前导零的唯一方法是将它们表示为文本值,因为大部分是前导零数字值时,数学函数无法操纵。 但是,我刚刚尝试了以下VBA代码并获得了结果
,如下所示:

Generally, the only way to display leading zeroes is to represent them as a text value since for the most part leading zeroes cannot be manipulated by math functions when in numeric values.  However, I just tried the following VBA code and got the results as follows:

   Dim s1 As String

   s1 =现在

   Debug.Print s1

   Debug.Print Format(s1," mm / dd / yy hh:nn:ss")

   Dim s1 As String
   s1 = Now
   Debug.Print s1
   Debug.Print Format(s1, "mm/dd/yy hh:nn:ss")

输出为:

5 / 15/2014 8:15:49 AM
05/15/14 08:15:49

5/15/2014 8:15:49 AM
05/15/14 08:15:49

- 请注意,s1是字符串var

--note that s1 is a string var


这篇关于文本框格式“hh”不显示领先零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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