在VBA用户窗体组合框中输入12:00 PM [英] Input 12:00 PM on VBA Userform Combobox

查看:43
本文介绍了在VBA用户窗体组合框中输入12:00 PM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示时间范围的vba用户窗体组合框.在行源中,我输入了12:00 PM.但是每次我在组合框中单击12:00 PM时,它就会显示12:05 AM.知道如何解决这个问题吗?

I have this vba userform combobox that shows time range. In the rowsource, i have inputted 12:00 PM. But everytime i click 12:00 PM in the combobox, it shows 12:05 AM instead. Any idea how to solve this problem?

推荐答案

使用点击事件而不是更改事件

Use click event instead of change event

Private Sub ComboBox5_Click()
    Dim t As Double

    With ComboBox5
        t = Val(.List(.ListIndex))
        .Value = Format(t, "hh:mm:ss AM/PM")
    End With

End Sub

这篇关于在VBA用户窗体组合框中输入12:00 PM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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