Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Controlling Size of VB5 InputBox

Posted on 1998-06-11
6
396 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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