Userform Text.Box中的日期未显示插入的数据

时间:2017-01-16 08:03:38

标签: date textbox outlook-vba userform

我有一个简单的用户表单,其中包含用户插入日期的文本框和用户插入数字的另一个文本框。当我尝试使用表单中的数据时,它不会显示插入的数据:日期显示为12:00:00 am,数字显示为0.

这是userform

Public Sub CancelButton_Click()
 Unload Me
 End
End Sub

Public Sub UserForm_Initialize()
 TextBox1.Value = ""
 TextBox2.Value = ""
End Sub

Public Sub btnOK_Click()
Dim xSO As Date
Dim ySO As String
 xSO = Format(TimeValue(TextBox1.Value), "dd.mm.yyyy")
 ySO = TextBox2.Value
Unload Me
End Sub

这是最低要求:

Public xSO As Long, ySO As Long
    Sub ffffff()
    Dim x As Date, y As String
            UserForm19.Show

             x = xSO 'Format(TextBox1.Value, "dd.mm.yyyy")
             y = ySO 'UserForm19.TextBox2.text

    MsgBox x
    MsgBox y

    End Sub

1 个答案:

答案 0 :(得分:0)

您声明了xSO和ySO两次。

从Public Sub btnOK_Click()

中删除本地声明
Dim xSO As Date
Dim ySO As String