InputBox - default characters

T

Tempy

Hi all,

I have an input box that requests a customer number, however the number
always starts with 0074-08-****. I only need the last part. Is there
some way with an Inputbox that i can make it default the first 6
characters and then the user must just type in the required figurs.

In other words the box has the first numbers in, which cannot be changed
and he/she must just add the remainder.

I hope i have explained mysel correctly.

Les Stout
 
F

Frank Kabel

Hi
though this default can be changed you may try:
application.InputBox(Prompt:= "Enter a value", Default:="0074-08-")

and check the return value if it's valid
 
T

Tempy

Hi Frank,
I have just treid your code and i get an error message '=' is expected ?

Les Stout
 
F

Frank Kabel

O.K.
you have to assign the return value of the inputbox to a variable.
something like:

sub foo()
Dim ret_value
ret_value = application.InputBox(Prompt:= "Enter a value",
Default:="0074-08-")
msgbox "The following was entered: " & ret_value
end if
 
C

Chip Pearson

Les,

Try something like

Dim Res As String
Res = InputBox(prompt:="Enter a value", Default:="0074-08-")
If StrPtr(Res) = 0 Then
MsgBox "You clicked cancel"
Else
MsgBox "You entered: " & Res
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
T

Tom Ogilvy

Sub Tester1()
Dim sAnswer As String
sAns = Application.InputBox( _
Prompt:="Enter a value", Default:="0074-08-")
MsgBox sAns
End Sub
 
T

Tempy

Thanks to all for your input.

Thom, that is exaclty what i had in mind, thank you.

You gents are doing a sterling job.

Les Stout
 
T

Tempy

Hi Thom,

further to my request, is it possible to "Secure" the default, so that
the user cannot overwrite it ?

Thanks,

Les Stout
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Inputbox default Question 3
Inputbox used for password 2
InputBox entries & advice 16
InputBox help please 6
InputBox Question 4
Cancel Input Box error 16
InputBox 3
inputbox 3

Top