Class Notes (1,100,000)
US (480,000)
UMD (9,000)
BMGT (500)
Lecture 9

BMGT 302 Lecture Notes - Lecture 9: Sqr


Department
Business and Management
Course Code
BMGT 302
Professor
Peter Huang
Lecture
9

This preview shows half of the first page. to view the full 1 pages of the document.
Exam questions about comparisons: 1 similarity and 2 differences
Sub Test()
Dim strAnswer As String
strAnswer = InputBox("How old are you?")
InputBox (prompt, [title], [default], [xpos], [ypos])
Prompt: question in box
Title: title in top of box
Default: what displays automatically in the input area
Xpos: position on screen; 0 means top left box
Ypos: position on screen; 0 means top left box too
strAnswer = InputBox("How old are you?", "Question 1", "(enter
your answer here)", 0, 0)
strAnswer = InputBox("How old are you?", "Question 1", _
"(enter your answer here)", 0, 0)
Range("A1").Value = strAnswer
MsgBox ("Your age is " & strAnswer & " years old.")
MsgBox (prompt, [buttons], [title])
Prompt: can use a variable that was previously assigned a value
If you want to display “Your age is “ + age, you can use the “&” or + , but & is preferred for VBA
If you put a value in the middle of a sentence, you should put & on both sides of the variable
Yes or No questions
- Use MsgBox and declare variables As VbMsgBoxResult.
- In MsgBox parentheses use vbYesNo after the prompt question
Ex:
First, enter a number into cell A1.
MsgBox "Entered value is " & Range("A1").Value
Immediate window using Excel Functions
Range("A6").Value = Application.WorksheetFunction.SUM(Range("A1:A5"))
Range("B6").Value = SQR(Range("A5"))
find more resources at oneclass.com
find more resources at oneclass.com
You're Reading a Preview

Unlock to view full version