Displays a prompt in a dialog box, waits for the user to input text or click a button, and then returns a string containing the contents of the text box.
InputBox(prompt[,title][,default][,xpos][,ypos][,helpfile,context])
Where:
prompt = Your message to user
title = title of your prompter
default = default value in the inputbox field
the rest are optional, rarely used by programmers
Example:
Dim A As Long
A = Application.InputBox("Please Enter Value <= 5", "Warning!", "Enter Value Here")
Another example of perfect code to use inputbox:
Sub Test()
Dim A As Long
A = Application.InputBox("Please Enter Value <= 5", "Warning!", "Enter Value Here")
If A = False Then Exit Sub
If A <= 5 Then
Range("A1") = A
Else
Do
MsgBox ("Your number is greater than 5")
A = Application.InputBox("Please Enter Value <= 5", "Warning!", "Enter Value Here")
Loop While A > 5
Range("A1") = A
End If
End Sub
No comments:
Post a Comment