dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: inputbox problem

  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    inputbox problem

    If cancel is pressed, "" is returned. If text box is left blank and OK is pressed, "" is returned. The problem is that I need to keep the value that was set before if cancel is pressed and if field is blank and OK is pressed, I need to set label to "". I need to determine if OK was pressed or Cancel was pressed. I was using

    istr = inputbox (blah)
    if istr <> "" then whatever

    well it doesn't work in this case because if istr = "" i need to check if "" was returned by pressing OK or Cancel. Thanks.

  2. #2
    Join Date
    Apr 2002
    Location
    Belgium
    Posts
    125
    You can create a form that looks like an input box.
    Bert Willekens,

  3. #3
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090
    Code:
    Private Sub Command1_Click()
    'Using StrPtr of the returned string should give you what you want. 
       Dim Answer As String
       Answer = InputBox("Enter something:")
       If StrPtr(Answer) = 0 Then
          MsgBox "Cancel was cliked!", vbInformation
          'put your code here
       Else
          MsgBox "Ok was cliked!", vbInformation
          'put your code here
       End If
    End Sub
    Last edited by Cimperiali; November 11th, 2003 at 04:48 PM.

  4. #4
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817
    Sweet, strptr, never heard of it. Thanks.

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    This one is to save

    Always nice to discover and recover...
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)