Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default Input box question

I'm using the following code to capture the user entered Group ID:

vGp = Trim(InputBox("Enter Group ID or ""All"", "Customer Group"))

The input form has an OK and Cancel Button. The problem is vGP returns ""
if the user presses OK and does not enter anything or if they press the
Cancel button.

Is there a way to determine which button was pushed? The reason is I will
take different actions depending on which button was pushed.

Thanks for the help......

--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Input box question

Hi,

You could test for a null string

Sub sonic()
vGp = Trim(InputBox("Enter Group ID or All", "Customer Group"))
If vGp = vbNullString Then
'do something
MsgBox "Nullstring"
Else
'Do something else
End If
End Sub


"JT" wrote:

I'm using the following code to capture the user entered Group ID:

vGp = Trim(InputBox("Enter Group ID or ""All"", "Customer Group"))

The input form has an OK and Cancel Button. The problem is vGP returns ""
if the user presses OK and does not enter anything or if they press the
Cancel button.

Is there a way to determine which button was pushed? The reason is I will
take different actions depending on which button was pushed.

Thanks for the help......

--
JT

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Input box question

If you use the InputBox Method then the Cancel will equal False and can be
distinguished from the OK with a blank entry.



"JT" wrote:

I'm using the following code to capture the user entered Group ID:

vGp = Trim(InputBox("Enter Group ID or ""All"", "Customer Group"))

The input form has an OK and Cancel Button. The problem is vGP returns ""
if the user presses OK and does not enter anything or if they press the
Cancel button.

Is there a way to determine which button was pushed? The reason is I will
take different actions depending on which button was pushed.

Thanks for the help......

--
JT

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Input box question

Hi JT

Remove Trim from the inputbox and try this:

Sub test()
Dim vGp As String
vGp = InputBox("Enter Group ID or ""All""", "Customer Group")
If StrPtr(vGp) = 0 Then
MsgBox "Cancel button"
End If
vGp = Trim(vGp)
End Sub

HTH. Best wishes Harald

"JT" wrote in message
...
I'm using the following code to capture the user entered Group ID:

vGp = Trim(InputBox("Enter Group ID or ""All"", "Customer Group"))

The input form has an OK and Cancel Button. The problem is vGP returns ""
if the user presses OK and does not enter anything or if they press the
Cancel button.

Is there a way to determine which button was pushed? The reason is I will
take different actions depending on which button was pushed.

Thanks for the help......

--
JT


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input Box Question marcia2026 Excel Programming 3 September 9th 08 09:03 PM
Input Question Help James8309 Excel Programming 1 July 20th 08 08:49 AM
Input Box Question DonovansMom Excel Programming 3 October 23rd 07 12:53 PM
Check Input, into Input box question Les Stout[_2_] Excel Programming 2 June 21st 07 06:37 PM
Input Box Question StGermain Excel Discussion (Misc queries) 2 March 12th 07 05:14 PM


All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"