2015-04-15 56 views
0

我想強制我的用戶輸入一個值或按取消。輸入框有人按確定沒有輸入任何東西

這裏是我目前的代碼,但我無法找到如何在沒有輸入任何內容的情況下使用按下的OK按鈕。

感謝

InputBox: 
On Error GoTo Cancel 
var_TauxUS = InputBox("Veuillez aller sur www.xe.com et entrer le taux d'echange US/CAN:" & vbCrLf & vbCrLf & "Exemple: 1,26 (avec une virgule)", "TAUX US") 'La variable reçoit la valeur entrée dans l'InputBox 


    If StrPtr(var_TauxUS) = 0 Then 
     GoTo InputBox 
    ElseIf var_TauxUS <= 1 Then 
     MsgBox "Vous devez entrer un chiffre plus grand que 1" 
     GoTo InputBox 
    ElseIf var_TauxUS >= 1.35 Then 
     MsgBox "Vous devez entrer un chiffre plus petit que 1.36" 
     GoTo InputBox 
    Else 
     var_TauxUS = var_TauxUS + vECHANGEDEVISE 'Calculer l'échange de la devise 
     var_US = True 
     MsgBox "Nous commenceons a updater les prix à un taux de " & var_TauxUS & " - Merci!" 
     GoTo Programme 
    End If 

我想:

IsEmpty(var_TauxUS) 

If var_TauxUS = "" then 

和它不工作

回答

1

下面是一個樣本,讓你開始:

Sub test() 
    Do 
     var_TauxUS = InputBox("Enter here:") 

     If StrPtr(var_TauxUS) = 0 Then 
      Exit Sub 
     End If 
    Loop While var_TauxUS = vbNullString 
End Sub 
相關問題