Solved

Controlling Size of VB5 InputBox

Posted on 1998-06-11
6
388 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now