Library tutorials & articles
Input Box function
Usage
The code below displays the dialog box we saw in the introduction.
InputBox "Please enter the documents title","Enter Title", "Document 1"
However, we need to know what the user entered! The InputBox function returns a string, which is the text the user entered in the Input Box.
DocName As String
DocName = InputBox ("Please enter the documents title", _
"Enter Title", "Document 1")
Msgbox "The documents title is " & DocName
This displays an input box asking the user for a documents title. When the user clicks OK then a Message Box will be displayed showing the text the user entered. You will notice that if you press cancel, the message box is still displayed. When the cancel button is pressed, the InputBox returns an empty string. You can edit the code so the message box is not displayed if the user presses cancel, or does not type anything:
DocName As String
DocName = InputBox ("Please enter the documents title", _
"Enter Title", "Document 1")
' If DocName is not empty, display the message box
If Not DocName = "" Then Msgbox "The documents title
is " & DocName
Related articles
Related discussion
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
-
Can you describe Above simple VB6 code?
by pramodmca09 (0 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
I want to reduce the width of text box on InputBox & to change the location of the Buttons & textbox,
is it possible?
Regards
Mahesh
what i want is a login form, but i cant get it to keep focus like when you have a messagebox or inputbox open you cant click the main form, how do i do that??
Suppose they just don't put anything in the box and click OK?
Unfortunately the input box isn't all the flexible. (You can't even hide the Cancel button.) You should use a custom form, it looks neater for getting 2 pieces of info anyway.
I have a requirement whereby the program has to wait for input of userid and password . Input box works fine but I am not able to make the password as password field. is there any property in input box to achieve this
Or
I have to use something else. If so then what shud i use.
Regards
Tirthankar
Do this....
i = InputBox("Question: blahblahblah?", "Q&A")
If i = "" Then Exit Sub ' leaves sub if the variable i is null
YOUR CODE HERE
Do this....
i = InputBox("Question: blahblahblah?", "Q&A")
If i = "" Then Exit Sub ' leaves sub if the variable i is null
YOUR CODE HERE
To end it, just add the line "exit sub" to your If statement where the string = "".
I made a small program (guessing game) that uses the inputbox, but how would I go about ending it when they choose cancel and not get an Error?
u didn't answer it so i started a new topic:
the codes with the () do it too!
it says "statement invalid outside type block" (and i always put it in the button click...)
and when i press ok it shows me the code:
Private Sub Command1_Click() -in yellow
DocName As String -in blue
and the rest of the code is ok.....
what's the problam?
??????
the codes with the () do it too!
it says "statement invalid outside type block" (and i always put it in the button click...)
and when i press ok it shows me the code:
Private Sub Command1_Click() -in yellow
DocName As String -in blue
and the rest of the code is ok.....
what's the problam?
??????
Apologies.
DocName = InputBox "Please enter the documents title", _
"Enter Title", "Document 1"
should have been
DocName = InputBox ("Please enter the documents title", _
"Enter Title", "Document 1")
I've corrected the article.
the later codes don't work!
why?
Is there a way to protect the contents entered into an input box?
ie..place asterisks over what someone types to protect a password.
If not...how can I prompt a user for input and protect what they enter using VB script...??
anywhere you wanna dude.
you can do this:
call inputbox("Do you really wanna?")
or
strBox= inputbox("Do ya?")
or even:
savesetting("WhatDa", "Who", "Ha", inputbox("Do da Day"))
not that hard, can be used anywhere you wanna
Does the code for Input Box go in the Load Form section?
This thread is for discussions of Input Box function.