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?

JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
Jussi Pohjolainen
 

Was ist angesagt? (20)

Functions in python slide share
Functions in python slide shareFunctions in python slide share
Functions in python slide share
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
 
6. static keyword
6. static keyword6. static keyword
6. static keyword
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Java script
Java scriptJava script
Java script
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 
JavaScript: Variables and Functions
JavaScript: Variables and FunctionsJavaScript: Variables and Functions
JavaScript: Variables and Functions
 
What is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | EdurekaWhat is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | Edureka
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Static Data Members and Member Functions
Static Data Members and Member FunctionsStatic Data Members and Member Functions
Static Data Members and Member Functions
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
 
Anonymous functions in JavaScript
Anonymous functions in JavaScriptAnonymous functions in JavaScript
Anonymous functions in JavaScript
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
JavaScript: Events Handling
JavaScript: Events HandlingJavaScript: Events Handling
JavaScript: Events Handling
 

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#
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 

Ä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.