Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 我有一个do-until循环,它使用一个布尔值和一个输入框。试图从输入循环中获取str变量_Vba_Excel - Fatal编程技术网

Vba 我有一个do-until循环,它使用一个布尔值和一个输入框。试图从输入循环中获取str变量

Vba 我有一个do-until循环,它使用一个布尔值和一个输入框。试图从输入循环中获取str变量,vba,excel,Vba,Excel,在visualbasics中,我有一个do-until循环来确保以正确的方式输入日期。如何在输入框中获取用户输入并将其保存为日期变量 Private Sub cmdbtn3_Click() 'create a booleanvariable Dim blDone As Boolean 'ask for there name strName = InputBox("Please Enter Your Name", "Step 1") 'create a do while not becaus

在visualbasics中,我有一个do-until循环来确保以正确的方式输入日期。如何在输入框中获取用户输入并将其保存为日期变量

Private Sub cmdbtn3_Click()

'create a booleanvariable
Dim blDone As Boolean

'ask for there name
strName = InputBox("Please Enter Your Name", "Step 1")

'create a do while not because we want a repeat until blDone is True
Do While Not blDone

    'set the value of the input box with the product list equal to the boolean
    'ask for the date of the start, have a do loop until date1
    blDone = InputBox("Please Enter the Estimated Starting Date of CU" & vbNewLine & "Example 05/24/2014") Like "##/##/####"


    'Create a msg that explains what the input must be
    If Not blDone Then MsgBox "the input didn't match the pattern '01/23/2014' where:" _
                              & vbNewLine & vbTab & "'01' must bethe month" _
                              & vbNewLine & vbTab & "'23' must be the date" _
                              & vbNewLine & vbTab & "'2014' must be the year"

'I need to save the value of the date as

Loop

End Sub

存储输入,然后对其进行比较。如果
dateInput
设置为
Date
类型,则检查失败,因为
01/01/2000
更改为
1/1/2000
。我通过在
Variant
中捕获它进行检查,然后将其转换并在最后存储在
dateOutput
中来解决这个问题

Private Sub cmdbtn3_Click()

'create a booleanvariable
Dim blDone As Boolean, dateInput As Variant, dateOutput As Date

'ask for there name
strName = InputBox("Please Enter Your Name", "Step 1")

'create a do while not because we want a repeat until blDone is True
Do While Not blDone

    'set the value of the input box with the product list equal to the boolean
    'ask for the date of the start, have a do loop until date1
    dateInput = InputBox("Please Enter the Estimated Starting Date of CU" & vbNewLine & "Example 05/24/2014")

    blDone = dateInput Like "##/##/####"

    'Create a msg that explains what the input must be
    If Not blDone Then MsgBox "the input didn't match the pattern '01/23/2014' where:" _
                              & vbNewLine & vbTab & "'01' must bethe month" _
                              & vbNewLine & vbTab & "'23' must be the date" _
                              & vbNewLine & vbTab & "'2014' must be the year"

'I need to save the value of the date as

Loop

dateOutput = CDate(dateInput)

End Sub

存储输入,然后对其进行比较。如果
dateInput
设置为
Date
类型,则检查失败,因为
01/01/2000
更改为
1/1/2000
。我通过在
Variant
中捕获它进行检查,然后将其转换并在最后存储在
dateOutput
中来解决这个问题

Private Sub cmdbtn3_Click()

'create a booleanvariable
Dim blDone As Boolean, dateInput As Variant, dateOutput As Date

'ask for there name
strName = InputBox("Please Enter Your Name", "Step 1")

'create a do while not because we want a repeat until blDone is True
Do While Not blDone

    'set the value of the input box with the product list equal to the boolean
    'ask for the date of the start, have a do loop until date1
    dateInput = InputBox("Please Enter the Estimated Starting Date of CU" & vbNewLine & "Example 05/24/2014")

    blDone = dateInput Like "##/##/####"

    'Create a msg that explains what the input must be
    If Not blDone Then MsgBox "the input didn't match the pattern '01/23/2014' where:" _
                              & vbNewLine & vbTab & "'01' must bethe month" _
                              & vbNewLine & vbTab & "'23' must be the date" _
                              & vbNewLine & vbTab & "'2014' must be the year"

'I need to save the value of the date as

Loop

dateOutput = CDate(dateInput)

End Sub