Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Input Box Vs Cancel

Hello All:
I have a code that will give me a input box to add name to the list.

newName = Application.InputBox("Type new student name:", "Add
Student", "New Student", Type:=2)
If newName = "" Or newName = "FALSE" Then
Exit Sub
End If

My problem is that the input box has OK, Cancel and the X windows
default close option in top upper right corner. If I add a name and
press OK all is fine. However the cancel and close window option will
create a name called FALSE. How would I make it exit sub once those
to functions are pressed.

Regards
Ardy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Input Box Vs Cancel

Change "FALSE" to "False" and it should work.

Ed

On Sep 5, 9:33 am, Ardy wrote:
Hello All:
I have a code that will give me a input box to add name to the list.

newName = Application.InputBox("Type new student name:", "Add
Student", "New Student", Type:=2)
If newName = "" Or newName = "FALSE" Then
Exit Sub
End If

My problem is that the input box has OK, Cancel and the X windows
default close option in top upper right corner. If I add a name and
press OK all is fine. However the cancel and close window option will
create a name called FALSE. How would I make it exit sub once those
to functions are pressed.

Regards
Ardy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Input Box Vs Cancel

On Sep 5, 10:31 am, Ed from AZ wrote:
Change "FALSE" to "False" and it should work.

Ed

On Sep 5, 9:33 am, Ardy wrote:

Hello All:
I have a code that will give me a input box to add name to the list.


newName = Application.InputBox("Type new student name:", "Add
Student", "New Student", Type:=2)
If newName = "" Or newName = "FALSE" Then
Exit Sub
End If


My problem is that the input box has OK, Cancel and the X windows
default close option in top upper right corner. If I add a name and
press OK all is fine. However the cancel and close window option will
create a name called FALSE. How would I make it exit sub once those
to functions are pressed.


Regards
Ardy

Ed:
Great, So Simple..... Could you explain a bit what is the difference
between the two.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Input Box Vs Cancel

The difference is simply the use of all caps (FALSE) or Title Case
(False). As you step through your code with F8, you can mouse over
variables and see what they contain. When I moused over newName, it
contained "False", which does not match "FALSE", so it didn't get
caught in your If statement.

I also hope you have an error trap at some point to catch the person
who hits Enter too quickly and gives you "New Student", since that's
your default for the InputBox.

Ed


On Sep 5, 10:52 am, Ardy wrote:
On Sep 5, 10:31 am, Ed from AZ wrote:



Change "FALSE" to "False" and it should work.


Ed


On Sep 5, 9:33 am, Ardy wrote:


Hello All:
I have a code that will give me a input box to add name to the list.


newName = Application.InputBox("Type new student name:", "Add
Student", "New Student", Type:=2)
If newName = "" Or newName = "FALSE" Then
Exit Sub
End If


My problem is that the input box has OK, Cancel and the X windows
default close option in top upper right corner. If I add a name and
press OK all is fine. However the cancel and close window option will
create a name called FALSE. How would I make it exit sub once those
to functions are pressed.


Regards
Ardy


Ed:
Great, So Simple..... Could you explain a bit what is the difference
between the two.- Hide quoted text -

- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Input Box Vs Cancel

Just to add to Ed's explanation...

VBA is case sensitive when you're comparing text (unless you tell the module not
to be).

So "False" is different from "FALSE" is different from "FaLsE"...

And I bet you declared newName as a string--so the boolean False was changed to
the string "False".

I may have used:

dim newName as variant
newname = application.inputbox(...)
if newname = "" _
or newname = False then ' this checks for the boolean false--not a string.
...

But I would have really used Inputbox (without application.inputbox).

dim NewName as string
newname = inputbox(...)
if trim(newname) = "" then
'they canceled
else
'they didn't
end if

I guess I don't see the benefit of using application.inputbox(type:=2) to return
a text string.

Ardy wrote:

On Sep 5, 10:31 am, Ed from AZ wrote:
Change "FALSE" to "False" and it should work.

Ed

On Sep 5, 9:33 am, Ardy wrote:

Hello All:
I have a code that will give me a input box to add name to the list.


newName = Application.InputBox("Type new student name:", "Add
Student", "New Student", Type:=2)
If newName = "" Or newName = "FALSE" Then
Exit Sub
End If


My problem is that the input box has OK, Cancel and the X windows
default close option in top upper right corner. If I add a name and
press OK all is fine. However the cancel and close window option will
create a name called FALSE. How would I make it exit sub once those
to functions are pressed.


Regards
Ardy

Ed:
Great, So Simple..... Could you explain a bit what is the difference
between the two.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Input Box Vs Cancel

On Sep 5, 7:50 pm, Dave Peterson wrote:
Just to add to Ed's explanation...

VBA is case sensitive when you're comparing text (unless you tell the module not
to be).

So "False" is different from "FALSE" is different from "FaLsE"...

And I bet you declared newName as a string--so the boolean False was changed to
the string "False".

I may have used:

dim newName as variant
newname = application.inputbox(...)
if newname = "" _
or newname = False then ' this checks for the boolean false--not a string.
...

But I would have really used Inputbox (without application.inputbox).

dim NewName as string
newname = inputbox(...)
if trim(newname) = "" then
'they canceled
else
'they didn't
end if

I guess I don't see the benefit of using application.inputbox(type:=2) to return
a text string.





Ardy wrote:

On Sep 5, 10:31 am, Ed from AZ wrote:
Change "FALSE" to "False" and it should work.


Ed


On Sep 5, 9:33 am, Ardy wrote:


Hello All:
I have a code that will give me a input box to add name to the list.


newName = Application.InputBox("Type new student name:", "Add
Student", "New Student", Type:=2)
If newName = "" Or newName = "FALSE" Then
Exit Sub
End If


My problem is that the input box has OK, Cancel and the X windows
default close option in top upper right corner. If I add a name and
press OK all is fine. However the cancel and close window option will
create a name called FALSE. How would I make it exit sub once those
to functions are pressed.


Regards
Ardy

Ed:
Great, So Simple..... Could you explain a bit what is the difference
between the two.


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Thanks Guys.....
I Think I will roll out the file as is, But I relly like Dave's
option of not using Application.InputBox. I need to play with this
and make this a bit more bulet proof. as of now there are some holes
in the applet, which I need to work on. I must have to admit it is
really good learning while doing an practical project. My many thanks
to all of you.

Ardy

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Input Box Vs Cancel

On Sep 5, 11:42 pm, Ardy wrote:
On Sep 5, 7:50 pm, Dave Peterson wrote:





Just to add to Ed's explanation...


VBA is case sensitive when you're comparing text (unless you tell the module not
to be).


So "False" is different from "FALSE" is different from "FaLsE"...


And I bet you declared newName as a string--so the boolean False was changed to
the string "False".


I may have used:


dim newName as variant
newname = application.inputbox(...)
if newname = "" _
or newname = False then ' this checks for the boolean false--not a string.
...


But I would have really used Inputbox (without application.inputbox).


dim NewName as string
newname = inputbox(...)
if trim(newname) = "" then
'they canceled
else
'they didn't
end if


I guess I don't see the benefit of using application.inputbox(type:=2) to return
a text string.


Ardy wrote:


On Sep 5, 10:31 am, Ed from AZ wrote:
Change "FALSE" to "False" and it should work.


Ed


On Sep 5, 9:33 am, Ardy wrote:


Hello All:
I have a code that will give me a input box to add name to the list.


newName = Application.InputBox("Type new student name:", "Add
Student", "New Student", Type:=2)
If newName = "" Or newName = "FALSE" Then
Exit Sub
End If


My problem is that the input box has OK, Cancel and the X windows
default close option in top upper right corner. If I add a name and
press OK all is fine. However the cancel and close window option will
create a name called FALSE. How would I make it exit sub once those
to functions are pressed.


Regards
Ardy
Ed:
Great, So Simple..... Could you explain a bit what is the difference
between the two.


--


Dave Peterson- Hide quoted text -


- Show quoted text -


Thanks Guys.....
I Think I will roll out the file as is, But I relly like Dave's
option of not using Application.InputBox. I need to play with this
and make this a bit more bulet proof. as of now there are some holes
in the applet, which I need to work on. I must have to admit it is
really good learning while doing an practical project. My many thanks
to all of you.

Ardy- Hide quoted text -

- Show quoted text -


Hau guys what happen to the star ratings..........

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 Cancel Jase Excel Discussion (Misc queries) 2 September 15th 08 11:42 PM
Input Box - CANCEL Danny Excel Worksheet Functions 6 December 1st 06 02:15 AM
Input Box - Hit cancel Steven Excel Programming 5 October 10th 06 04:23 PM
Input box to cancel sub when Cancel is clicked. PCLIVE Excel Programming 5 September 5th 06 03:19 PM
cancel input ME @ Home Excel Discussion (Misc queries) 1 February 22nd 06 09:49 AM


All times are GMT +1. The time now is 10:32 AM.

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

About Us

"It's about Microsoft Excel"