Visual Basic > Visual Basic Forums > Visual Basic Interop and Upgrade > InputBox backwards compatibility problem
Ask a questionAsk a question
 

AnswerInputBox backwards compatibility problem

  • Monday, October 26, 2009 8:25 PMCollin Sauve Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    There seems to be a problem with the InputBox that Microsoft gives us for backwards compatibility.   In VB6, if the user clicked cancel, it used to give back a string with a 0 pointer.   Now it gives back String.Empty.  Unfortunately this is ambiguous with the user clearing the text and clicking OK.

    In VB6 you used to be able to do this;
    Dim input as String
    input = InputBox("Enter some text, or else")
    If StrPtr(input) = 0 Then
      Msgbox("You clicked cancel.")
    End If
    
    Is there any way in .Net to duplicate this behavior?  Our program logic depends on being able to differentiate between a Cancel and an OK with blank text.  I would prefer not to have to write my own input dialog, but may have to if there is no other solution.


    Collin Sauve

Answers

  • Thursday, October 29, 2009 12:51 PMRiquel_DongModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Collin,

    I think that you can use the customized Dialof(using form) to implement this requirement. I didn't find any parameters to supply your required information in this situation.
    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

All Replies

  • Thursday, October 29, 2009 12:51 PMRiquel_DongModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Collin,

    I think that you can use the customized Dialof(using form) to implement this requirement. I didn't find any parameters to supply your required information in this situation.
    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.