SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Parul Institute Of Engineering & Technology


Subject code:- 151006
Name of subject:- Visual Basic And Application


Name of unit:- Using Intrinsic Dialogs


(Topic):- InputBox


Name of faculty:- 1) Ms.Nupur mam


Name of students:- 1) Vivek Patel (Roll.no- 146)
                     2) Sagar Pandya (Roll.no-140)
InputBox
 Defination:
   InputBox is used to accept input from the user.
   An inputBox is a pop up box,similar to a
    message box which has a textBox.
   It also has a “OK” and “CANCEL” buttons.
   Syntax:

   InputBox(prompt [, title ] [, default ] [, xpos ]
    [, ypos ] [, helpfile ] [, context ] )
   A way to ask a user of your system a question
    is to use an Inputbox:
   Here's what we're trying to achieve:
   Ask the question:


   Display the answer:
   Here's the code:

   InputBox takes several arguments:
      Prompt
      Title
      Default
      Xpos
      Ypos
      HelpFile
      Context
   In this example, we have entered:
      Prompt: "How Many Apples Do You Want?"
      Title: "Apples"
      Default: 3


   We then display the choice back to the user,
    but using this in a practical way, we'd trap the
    answer and use it for something else
We check whether the return from the box is
""
   If "" then they've pressed the Cancel
   button, and we should exit.
Getting User Input With a
VBA Input Box
   This could be useful if you wanted to fill up a
    page with text and print it to see if the margins
    etc. look OK.
   1. Open a new document in Word.
   2. Open the VBA Editor (Tools>Macro>Visual
    Basic Editor).
   3. Copy the following text from Sub
    InputBoxInsertText() to End Sub, inclusively.
   Sub InputBoxInsertText()
     Selection.HomeKey wdStory
     TheSentence = InputBox("Type Text Please", "Using
    the VBA Input Box")
     HowManyTimes = InputBox("How many times",
    "Using the VBA Input Box")
     For Counter = 1 To HowManyTimes
     Selection.TypeText TheSentence & " "

    Next

    End Sub
   4. Put the cursor anywhere within this code
    block.
   5. Press F5
   6. Type a word or two into the first VBA input
    box that appears.
   7. Type a number (between 50 and 100) into
    the second Input Box.
8. Go to the new document you opened and see
how the word or two that you typed into the
input box appears repeated the amount of times
corresponding to value you entered into the
second input box.
ARGUMENT
 prompt :
   Required.
   String expression displayed as the message in
    the dialog box. The maximum length
    ofprompt is approximately 1024 characters,
    depending on the width of the characters
    used.
   Ifprompt consists of more than one line, you
    can separate the lines using a carriage return
    character , a linefeed character , or carriage
    return–linefeed character combination
 title   :
   Optional. String expression displayed in the
    title bar of the dialog box. If you omit title, the
    application name is placed in the title bar.
 Default:
   Optional. String expression displayed in the
    text box as the default response if no other
    input is provided. If you omit default, the text
    box is displayed empty.
 Xpos:
   Optional.
   Numeric expression that specifies, in twips,
    the horizontal distance of the left edge of the
    dialog box from the left edge of the screen.
    If xpos is omitted, the dialog box is
    horizontally centered.
 Ypos:
   Optional.
   Numeric expression that specifies, in twips,
    the vertical distance of the upper edge of the
    dialog box from the top of the screen.
   If ypos is omitted, the dialog box is vertically
    positioned approximately one-third of the way
    down the screen.
 Helpfile:
   Optional.
   String expression that identifies the Help file to
    use to provide context-sensitive Help for the
    dialog box.
   If helpfile is provided, context must also be
    provided.
INPUT BOX- VBA

Weitere ähnliche Inhalte

Was ist angesagt?

Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0
Salim M
 

Was ist angesagt? (20)

Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Oops in vb
Oops in vbOops in vb
Oops in vb
 
JSpiders - Wrapper classes
JSpiders - Wrapper classesJSpiders - Wrapper classes
JSpiders - Wrapper classes
 
array of object pointer in c++
array of object pointer in c++array of object pointer in c++
array of object pointer in c++
 
Php forms
Php formsPhp forms
Php forms
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Interface
InterfaceInterface
Interface
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Creating your own exception
Creating your own exceptionCreating your own exception
Creating your own exception
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Tkinter_GUI_Programming_in_Python.pdf
Tkinter_GUI_Programming_in_Python.pdfTkinter_GUI_Programming_in_Python.pdf
Tkinter_GUI_Programming_in_Python.pdf
 
Php array
Php arrayPhp array
Php array
 
[OOP - Lec 07] Access Specifiers
[OOP - Lec 07] Access Specifiers[OOP - Lec 07] Access Specifiers
[OOP - Lec 07] Access Specifiers
 
String operation
String operationString operation
String operation
 
Javascript validating form
Javascript validating formJavascript validating form
Javascript validating form
 
Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Function in C Language
Function in C Language Function in C Language
Function in C Language
 

Andere mochten auch

VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedure
pragya ratan
 
Menu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vbMenu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vb
Amandeep Kaur
 
Dotnet framework
Dotnet frameworkDotnet framework
Dotnet framework
Nitu Pandey
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
Doncho Minkov
 

Andere mochten auch (20)

Objects and classes in Visual Basic
Objects and classes in Visual BasicObjects and classes in Visual Basic
Objects and classes in Visual Basic
 
InputBox
InputBoxInputBox
InputBox
 
Notas InputBox
Notas InputBoxNotas InputBox
Notas InputBox
 
Procedures functions structures in VB.Net
Procedures  functions  structures in VB.NetProcedures  functions  structures in VB.Net
Procedures functions structures in VB.Net
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedure
 
Part19 inputbox using for..loop
Part19 inputbox using for..loopPart19 inputbox using for..loop
Part19 inputbox using for..loop
 
CALCULADORA INPUTBOX
CALCULADORA INPUTBOXCALCULADORA INPUTBOX
CALCULADORA INPUTBOX
 
Menu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vbMenu pop up menu mdi form and playing audio in vb
Menu pop up menu mdi form and playing audio in vb
 
Object oriented programming concepts
Object oriented programming conceptsObject oriented programming concepts
Object oriented programming concepts
 
Debugging
DebuggingDebugging
Debugging
 
Dotnet framework
Dotnet frameworkDotnet framework
Dotnet framework
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
 
Uso de la función InputBox y MsgBox
Uso de la función InputBox y MsgBoxUso de la función InputBox y MsgBox
Uso de la función InputBox y MsgBox
 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
Exception handling
Exception handlingException handling
Exception handling
 

Ähnlich wie INPUT BOX- VBA

Looping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxLooping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptx
adihartanto7
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
fredharris32
 
Hello, I need help with the following assignmentThis assignment w.pdf
Hello, I need help with the following assignmentThis assignment w.pdfHello, I need help with the following assignmentThis assignment w.pdf
Hello, I need help with the following assignmentThis assignment w.pdf
namarta88
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
wilcockiris
 
Notes1
Notes1Notes1
Notes1
hccit
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
J. C.
 
Hey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addiHey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addi
sorayan5ywschuit
 
Vb6 ch.8-3 cci
Vb6 ch.8-3 cciVb6 ch.8-3 cci
Vb6 ch.8-3 cci
Fahim Khan
 

Ähnlich wie INPUT BOX- VBA (20)

Looping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptxLooping in PythonLab8 lecture slides.pptx
Looping in PythonLab8 lecture slides.pptx
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
 
Tm 1st quarter - 2nd meeting
Tm   1st quarter - 2nd meetingTm   1st quarter - 2nd meeting
Tm 1st quarter - 2nd meeting
 
Hello, I need help with the following assignmentThis assignment w.pdf
Hello, I need help with the following assignmentThis assignment w.pdfHello, I need help with the following assignmentThis assignment w.pdf
Hello, I need help with the following assignmentThis assignment w.pdf
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
 
Python assignment 4
Python assignment 4Python assignment 4
Python assignment 4
 
I x scripting
I x scriptingI x scripting
I x scripting
 
Notes1
Notes1Notes1
Notes1
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by Example
 
Winisisx
WinisisxWinisisx
Winisisx
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
 
F# Console class
F# Console classF# Console class
F# Console class
 
python1.ppt
python1.pptpython1.ppt
python1.ppt
 
Wp100963 jython scripting with wsadmin tutorial
Wp100963   jython scripting with wsadmin tutorialWp100963   jython scripting with wsadmin tutorial
Wp100963 jython scripting with wsadmin tutorial
 
Hey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addiHey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addi
 
Python for Physical Science.pdf
Python for Physical Science.pdfPython for Physical Science.pdf
Python for Physical Science.pdf
 
PYTHON 101.pptx
PYTHON 101.pptxPYTHON 101.pptx
PYTHON 101.pptx
 
Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make Question 1 briefly respond to all the following questions. make
Question 1 briefly respond to all the following questions. make
 
Vks python
Vks pythonVks python
Vks python
 
Vb6 ch.8-3 cci
Vb6 ch.8-3 cciVb6 ch.8-3 cci
Vb6 ch.8-3 cci
 

Mehr von ViVek Patel (7)

Cdma wireless security
Cdma wireless securityCdma wireless security
Cdma wireless security
 
Report on wireless System CDMA security
Report on wireless System CDMA securityReport on wireless System CDMA security
Report on wireless System CDMA security
 
Any Surface Drum Kit
Any Surface Drum Kit Any Surface Drum Kit
Any Surface Drum Kit
 
Code Division Multiple Access- CDMA
Code Division Multiple Access- CDMA Code Division Multiple Access- CDMA
Code Division Multiple Access- CDMA
 
E-town Banking system
E-town Banking systemE-town Banking system
E-town Banking system
 
Programming 8051 Timers
Programming 8051 Timers Programming 8051 Timers
Programming 8051 Timers
 
Introduction to Strategic Managment
Introduction to Strategic ManagmentIntroduction to Strategic Managment
Introduction to Strategic Managment
 

INPUT BOX- VBA

  • 1. Parul Institute Of Engineering & Technology Subject code:- 151006 Name of subject:- Visual Basic And Application Name of unit:- Using Intrinsic Dialogs (Topic):- InputBox Name of faculty:- 1) Ms.Nupur mam Name of students:- 1) Vivek Patel (Roll.no- 146) 2) Sagar Pandya (Roll.no-140)
  • 2. InputBox  Defination:  InputBox is used to accept input from the user.  An inputBox is a pop up box,similar to a message box which has a textBox.  It also has a “OK” and “CANCEL” buttons.
  • 3. Syntax:  InputBox(prompt [, title ] [, default ] [, xpos ] [, ypos ] [, helpfile ] [, context ] )
  • 4. A way to ask a user of your system a question is to use an Inputbox:  Here's what we're trying to achieve:  Ask the question: 
  • 5. Display the answer:
  • 6. Here's the code: 
  • 7. InputBox takes several arguments:  Prompt  Title  Default  Xpos  Ypos  HelpFile  Context
  • 8. In this example, we have entered:  Prompt: "How Many Apples Do You Want?"  Title: "Apples"  Default: 3  We then display the choice back to the user, but using this in a practical way, we'd trap the answer and use it for something else
  • 9. We check whether the return from the box is "" If "" then they've pressed the Cancel button, and we should exit.
  • 10. Getting User Input With a VBA Input Box  This could be useful if you wanted to fill up a page with text and print it to see if the margins etc. look OK.  1. Open a new document in Word.  2. Open the VBA Editor (Tools>Macro>Visual Basic Editor).  3. Copy the following text from Sub InputBoxInsertText() to End Sub, inclusively.
  • 11. Sub InputBoxInsertText() Selection.HomeKey wdStory TheSentence = InputBox("Type Text Please", "Using the VBA Input Box") HowManyTimes = InputBox("How many times", "Using the VBA Input Box") For Counter = 1 To HowManyTimes Selection.TypeText TheSentence & " " Next End Sub
  • 12. 4. Put the cursor anywhere within this code block.  5. Press F5  6. Type a word or two into the first VBA input box that appears.  7. Type a number (between 50 and 100) into the second Input Box.
  • 13. 8. Go to the new document you opened and see how the word or two that you typed into the input box appears repeated the amount of times corresponding to value you entered into the second input box.
  • 14. ARGUMENT  prompt :  Required.  String expression displayed as the message in the dialog box. The maximum length ofprompt is approximately 1024 characters, depending on the width of the characters used.  Ifprompt consists of more than one line, you can separate the lines using a carriage return character , a linefeed character , or carriage return–linefeed character combination
  • 15.  title :  Optional. String expression displayed in the title bar of the dialog box. If you omit title, the application name is placed in the title bar.  Default:  Optional. String expression displayed in the text box as the default response if no other input is provided. If you omit default, the text box is displayed empty.
  • 16.  Xpos:  Optional.  Numeric expression that specifies, in twips, the horizontal distance of the left edge of the dialog box from the left edge of the screen.  If xpos is omitted, the dialog box is horizontally centered.
  • 17.  Ypos:  Optional.  Numeric expression that specifies, in twips, the vertical distance of the upper edge of the dialog box from the top of the screen.  If ypos is omitted, the dialog box is vertically positioned approximately one-third of the way down the screen.
  • 18.  Helpfile:  Optional.  String expression that identifies the Help file to use to provide context-sensitive Help for the dialog box.  If helpfile is provided, context must also be provided.