InputBox - default characters

  • Thread starter Thread starter Tempy
  • Start date Start date
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
 
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
 
Hi Frank,
I have just treid your code and i get an error message '=' is expected ?

Les Stout
 
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
 
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
 
Sub Tester1()
Dim sAnswer As String
sAns = Application.InputBox( _
Prompt:="Enter a value", Default:="0074-08-")
MsgBox sAns
End Sub
 
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
 
Hi Thom,

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

Thanks,

Les Stout
 
Back
Top