Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Box question

Status
Not open for further replies.

101287

MIS
Apr 8, 2006
189
US
How can I check the Input Box and determine if in the input box someone "click" the cancel.

Don't know how to check to code.

Suggestions, please.

Luis
 
If the result is null, cancel was clicked, or nothing was entered. Is that sufficient?

Code:
strResponse = InputBox("Enter: ", "Title", "Default")
If Trim(strResponse & " ") = "" Then
    MsgBox "Cancel Clicked"
Else
    MsgBox "OK Clicked"
End If
 
Remou . . .
Code:
[blue]If Trim(strResponse & "[COLOR=black red] [/color]") = "" Then[/blue]
This is not like you . . .

Calvin.gif
See Ya! . . . . . .
 
TheAceMan1

What do you see as the problem?

[tt]Debug.Print Len(Trim(strResponse & " ")) '0
Debug.Print Len(Trim(strResponse & "")) '0[/tt]
 
Interesting. A space, that has a Hex code, equates to 0 and a null that has no Hex code (by definition) also equates to 0. Some programmer messed up.
0 is not nothing, null, nil.
 
I think there is some misunderstanding. The idea, which I think was first suggested by PHV, is to add a space to a string and then trim the string to avoid nulls, check for zero length strings, and catch empty strings. I have found that both adding both "" and " " seem to give the same result, but I think PHV normally uses " ", so I guess there is a reason for it.

[tt]So
Trim(Null & " ")=""
Also
Trim ("" & " ")=""
And
Trim (" " & " ")=""[/tt]

yes no?
 
As per the stated web reference:
"vbNullString 'pointer' is zero." - by definition. Again, null is not 0.
Microsoft is being inconsistent (surprise). Set up an Average formula or function in Excel for three cells. Leave the cells empty (or null) and you'll get an error message in the formula cell - division by 0. Because there are no items in the cells. However, just place one 0 in a cell and the average will equate to 0, which is correct - there is now one item. This is because 0 is an actual object.
This is true in mathematics, logic and philosophy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top