ユーザーに住宅の頭金を提示するように求めます。購入費用は、別の場所で $235,000 に設定されています。ユーザーが購入費用の 10% 以上の頭金を提示するかどうかによって、応答は異なります。
Sub ProcessMortgage(cost As Single)
Dim downpmt As Single, msg As String
msg$ = "Cost: " + Format(cost!, "Currency") _
& ". Enter a down payment:"
downpmt! = CSng(InputBox(msg$))
If downpmt! < .1 * cost! GoTo NotEnough
msg$ = Format(downpmt!, "Currency") & " will do fine!"
MessageBox msg$
' Continue processing the application
' ...
' ...
Exit Sub
NotEnough:
msg$ = "Sorry, " & Format(downpmt!, "Currency") _
& " is not enough!"
MessageBox msg$
End Sub
Dim cost As Single
cost! = 235000
ProcessMortgage(cost!) ' Call the ProcessMortgage sub.