VBScript InputBox-functie

Definitie en gebruik

De InputBox-functie kan een dialoogvenster weergeven waarin de gebruiker tekst kan invoeren en/or een knop klikken. Als de gebruiker de bevestigingsknop klikt of de Enter-toets op de toetsenbord indrukt, retourneert de InputBox-functie de tekst in het tekstvak. Als de gebruiker de annuleringsknop klikt, retourneert de functie een lege string ("").

Opmerking:Als zowel het helpfile- als het context-parameter worden opgegeven, wordt er een helpknop toegevoegd aan het dialoogvenster.

Tip:Zie ook de MsgBox-functie.

syntaxis

InputBox(prompt[,title][,default][,xpos][,ypos][,helpfile,context])
parameter beschrijving
prompt Noodzakelijk. Real-time berichten in het dialoogvenster. De maximale lengte van de prompt is ongeveer 1024 karakters, afhankelijk van de breedte van de gebruikte karakters. Als de prompt meerdere regels bevat, kunnen de regels worden gescheiden door een Enter-teken (Chr(13)), een newline-teken (Chr(10)) of een combinatie van Enter en newline (Chr(13) & Chr(10)).
title Optional. String expression displayed in the dialog box title bar. If title is omitted, the name of the application will be displayed in the title bar.
default Optional. String expression displayed in the text box, used as the default response value when no other input is provided. If default is omitted, the text box is empty.
xpos Optional. Numeric expression, used to specify the horizontal distance from the left edge of the dialog box to the left edge of the screen (in points). If xpos is omitted, the dialog box is centered horizontally.
ypos Optional. Numeric expression, used to specify the vertical distance from the top edge of the dialog box to the top edge of the screen (in points). If ypos is omitted, the dialog box is displayed approximately one-third of the way down the screen vertically.
helpfile Optional. String expression, used to identify the help file that provides context-related help for the dialog box. If helpfile is provided, context must also be provided.
context Optional. Numeric expression, used to identify the context number specified by the author of the help file for a specific help topic. If context is provided, helpfile must also be provided.

Example

dim fname
fname=InputBox("Enter your name:")
MsgBox("Your name is " & fname)