Results 1 to 4 of 4

Thread: [RESOLVED] Catch cancel on inpoutbox

  1. #1

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Resolved [RESOLVED] Catch cancel on inpoutbox

    Guys,

    I have this code ....

    filename = InputBox("Please enter a filename", "Export Filename") & ".xls"

    However, if the user hits cancel my code still continues. How can I only capture the string if the user hits OK and the string is not blank ?

    Bob
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

  2. #2
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: Catch cancel on inpoutbox

    if the user hits cancel the string returned should be blank

    VB Code:
    1. dim returned As String = InputBox("Please enter a filename", "Export Filename")
    2. if not returned Is Nothing AndAlso returned.length > 0 Then
    3.   filename = returned & ".xls"
    4. End If

  3. #3

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Re: Catch cancel on inpoutbox

    Thanks Phil.

    Bob
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Catch cancel on inpoutbox

    Wouldn't you want to use a SaveFileDialog to get the file name, or are you just giving them the choice of file name but not folder location?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width