PDA

View Full Version : Solved: Inputbox Display Lines?



Simon Lloyd
09-27-2006, 12:37 PM
Hi all, i have an input box as shown below, it works fine, except i can only get the inputbox to display the first 4 lines, i.e it will not display "38 Pink" everything else it displays, does anyone know how to fix this?IBS = Application.InputBox("Enter Colour to Delete" & vbCrLf & _
Space(5) & "3 = Red" & vbCrLf & _
Space(5) & "4 = Green" & vbCrLf & _
Space(5) & "5 = Blue" & vbCrLf & _
Space(5) & "6 = Yellow" & vbCrLf & _
Space(5) & "38 = Pink", "Colour Deletion Selection", Type:=1)Regards,
Simon

mdmackillop
09-27-2006, 01:33 PM
I guess you've passed the InputBox size limits. Why not create a UserForm for your input?

Charlize
09-27-2006, 01:51 PM
Hi all, i have an input box as shown below, it works fine, except i can only get the inputbox to display the first 4 lines, i.e it will not display "38 Pink" everything else it displays, does anyone know how to fix this?IBS = Application.InputBox("Enter Colour to Delete" & vbCrLf & _
Space(5) & "3 = Red" & vbCrLf & _
Space(5) & "4 = Green" & vbCrLf & _
Space(5) & "5 = Blue" & vbCrLf & _
Space(5) & "6 = Yellow" & vbCrLf & _
Space(5) & "38 = Pink", "Colour Deletion Selection", Type:=1)Regards,
Simon

Must choose a value otherwise box will stay until you give input. Try 5555 and box is cleared because not in values that are allowed.

Sub input_boxes()
Dim ibs As String
Dim message As String
Dim heading As String
message = "Enter Colour to Delete" & vbCrLf & _
Space(5) & "3 = Red" & vbCrLf & Space(5) & "4 = Green" & vbCrLf & _
Space(5) & "5 = Blue" & vbCrLf & _
Space(5) & "6 = Yellow" & vbCrLf & _
Space(5) & "38 = Pink"
heading = "Colour Deletion"
Do While ibs = vbNullString
ibs = InputBox(message, heading)
If ibs = "3" Or ibs = "4" Or ibs = "5" Or ibs = "6" Or ibs = "38" Then
Exit Do
End If
ibs = ""
Loop
MsgBox (ibs & " was chosen")
End Sub

Charlize

mdmackillop
09-27-2006, 02:13 PM
Hi Charlize, I think you missed the point of ther question.

Simon Lloyd
09-27-2006, 03:13 PM
MD, i take your comment on board about the userform, it was just me being lazy as i had already created the input box and just wanted to display all that i had written neatly. I have now edited it to show just 4 lines of text now not as neat but minimal work!

Charlize, thanks for your efforts and revised code, i guess i did miss that about the user not selecting a number and it does give an error (theres me again no error handling and blind to it!), i wont use you code unless i have to i will try to build the error handling myself taking into account your example.

Thanks very much!

Regards,
Simon

Andy Pope
09-27-2006, 03:15 PM
The Application.Inputbox appears to be restricted to 5 lines and 255 characters.

More than 5 lines and the text is lost.
More that 255 characters and the box doesn't even appear!

You could use VBA's Inputbox function but the returned value will not automatically be restricted to a number, as there is no Type argument.

Charlize
09-27-2006, 03:27 PM
Hi Charlize, I think you missed the point of ther question.

Hello Md,

I think the question was "want to show 5 lines of choises and the last one doesn't show up". I gave the answer for 5 lines with checking for a number that was on the list (if you type anything else, the box will remain until you give a number on the list). If that wasn't the question, then I'm sorry that I didn't understood it.

I used inputbox. Simon used application.inputbox . Because I can't use type:=1 to say it must be a number, I have to find a solution for that.

Charlize