Thread: input box
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default input box

ps.

Don't bother using "as integer" or "as single" in your code.

Just use:
dim Max as long
dim AnotherNumber as Double

Integers and singles should be forgotten <bg.

Dave Peterson wrote:

First, it's better to copy directly from the VBE and paste into the body of your
message. Then typos are eliminated (no closing " in the Prompt parm).

Dim max As Integer

max = Application.InputBox(Prompt:="How many reports to create?", _
Title:="Create Reports ", Type:=1)

If max = 0 Then
MsgBox "either the user entered 0 or hit cancel"
Else
MsgBox max
End If

I like to use application.inputbox with type:=1 when I don't want to bother
validating input as a number. It's too easy to let excel/vba do that check.

thomas donino wrote:

Hello,

can some one explain why this doesnt work?

Sub test()
Dim i as Integer
Dim max as Integer

Set max = InputBox(Prompt:="How many reports to create?, Title:="Create
Reports", Type:=1)

msgbox max
End Sub

fyi in the code window the set max is all on one line


--

Dave Peterson


--

Dave Peterson