Solved

Controlling Size of VB5 InputBox

Posted on 1998-06-11
6
395 Views
Last Modified: 2010-05-03
In VB5 the InputBox Function will allow you to display a Title, a Prompt, a Default response, and a screen position.
Is it also possible to control the Height and Width of the InputBox and the Width of the Text Box?

Sample Code:
 
  Title$ = "USER INPUT"
  Prompt$ = "Enter a Number From 1 to 9"
  Default$ = "1"
  X = 1000
  Y = 1000
  Entry = InputBox(Prompt$, Title$, Default$, X, Y)
 
When this is executed, an input box appears on the screen which is much larger than I would like.  The text box where the user is supposed to enter a number from 1 to 9 is wide enough for a 50 digit number!  Is there any way to make it smaller?  Also is there any way to change the font in the Title, Prompt or Text Box?

If these changes are not possible, then does anyone have some code to simulate this input box in a way that these properties (height, width, textbox width and font) can be controlled?
0
Comment
Question by:dougr
6 Comments
 
LVL 2

Expert Comment

by:marti
ID: 1463173
You could just create a small VB form to get this done.
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1463174
marti is right, InputBox is a simple solution, but not a very flexible one. If you want something more then it can provide you, you must create your own form
0
 
LVL 9

Accepted Solution

by:
cymbolic earned 50 total points
ID: 1463175
It's really a trivial task to create your own form, but even then you would need to put some editing logic on your input text field if you wanted to restrict it just to numbers of less that two digits.  Since the input box needs sufficient size to display your prompt as well, you are going to have a larger than desired text entry area.  A simple solution is to place your input box call in a loop that edits for desired input characteristics, and re-requests until nothing is entered, or an acceptable entry is made.  It's still programmatically cheaper than rolling your own form!
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:dougr
ID: 1463176
cymbolic

I am a relative newcomer to Visual Basic, so what is a "trivial task" for some is somewhat more daunting for me.

Just so I am clear on what you are saying, I gather that it is impossible to:
  1. Change the size of an InputBox
  2. Change the Text Box width (of an InputBox)
  3. Change the Font within the text Box (of an InputBox)

Re creating a small VB Form, I still haven't mastered multiple forms - e.g. how to open several at once, how to handle mouse activity outside the form, which is front and back etc.

The solution I tend to use is to create a frame containing controls which simulate an InputBox (heading, buttons, labels etc).  I just render it visible when I need it and invisible when I don't

It takes a bit of code to do this, so I just thought there might be a more elegant solution - perhaps API's.  

dougr
0
 

Author Comment

by:dougr
ID: 1463177
cymbolic

I am a relative newcomer to Visual Basic, so what is a "trivial task" for some is somewhat more daunting for me.

Just so I am clear on what you are saying, I gather that it is impossible to:
  1. Change the size of an InputBox
  2. Change the Text Box width (of an InputBox)
  3. Change the Font within the text Box (of an InputBox)

Re creating a small VB Form, I still haven't mastered multiple forms - e.g. how to open several at once, how to handle mouse activity outside the form, which is front and back etc.

The solution I tend to use is to create a frame containing controls which simulate an InputBox (heading, buttons, labels etc).  I just render it visible when I need it and invisible when I don't

It takes a bit of code to do this, so I just thought there might be a more elegant solution - perhaps API's.  

dougr
0
 

Author Comment

by:dougr
ID: 1463178
Sorry, I got an error message from Experts Exchange when I submitted my comment, so I submitted it again.  That's why it appears twice.

dougr
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question