-
I am lost on this. I need to add what is added in an InputBox to a textbox on a form and to a field in a database. I want to have OK and Cancel. How can I check for Cancel and get the value?
Code:
Dim iResponse As Integer
iResponse = InputBox "Add Note"
If iResponse = 1 Then 'user hit Ok
'this will check for the cancel but how do I get
'the data entered
Dim strNote As String
strNote = InputBox("Enter Note for" & ListView1.SelectedItem, "Add Note")
'this get the data but not the Cancel
'How do I do this?
-
add an if...
Code:
if (strNote <> "") then
'whatever
end if
-
Code:
Dim iResponse As Integer
iResponse = InputBox "Add Note"
If iResponse = 1 Then 'user hit Ok
'this will check for the cancel but how do I get
'the data entered
Dim strNote As String
strNote = InputBox("Enter Note for" & ListView1.SelectedItem, "Add Note")
If strNote = "" Then Msgbox "Nothing entered!", vbCritical
'....
-
only one inputbox
I may have made my question a little confusing. I only want one InputBox to show up. I need to know if I can check the button and get the string. If not I can work around it. I just wanted to check the cancel button in case the user entered something then changed thier mind.
-
if the user hits cancel, the string will be empty, so mine, or Matthew's code will work.
-
I see what you want.
Code:
x = InputBox("How are you today?")
If x <> "" Then
Msgbox "Response: " & x
Else
Msgbox "Not having a good day?"
End If
-
<?>
this is all you need.
Dim strNote As String
strNote = InputBox("Enter Note for" & ListView1.SelectedItem, "Add Note")
If strNote = "" Then
MsgBox "You either picked nothing or pressed cancel"
Exit Sub
End If