Results 1 to 4 of 4

Thread: [VB.net] Input Box - cancel button

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2007
    Posts
    42

    Resolved [VB.net] Input Box - cancel button

    Hi there, I have a problem with INPUT BOX.

    This is it:

    Code:
    dim variable1 as double
    
    variable1 = CDbl(InputBox("What is your height?"))
    Now, varible1 is double and whem I enter value into input box it is working.

    Problem:
    When I click cancel button, it sends empty string to this variable which leads to this error.

    Conversion from string "" to type 'Double' is not valid.

    Any help for me?
    Last edited by [venom]; Dec 4th, 2007 at 08:32 PM.

  2. #2
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [VB.net] Input Box - cancel button

    Code:
    Dim MyDouble As Double = 0
    Dim SafelyConverted As Boolean = Double.TryParse(InputBox("What is your height?"), MyDouble)
    Cheers

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2007
    Posts
    42

    Re: [VB.net] Input Box - cancel button

    That's it.

    Thanks Icyculyr

  4. #4
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [VB.net] Input Box - cancel button

    NP please mark your thread as resolved, by editing the first post and selecting the 'Green Tick' at the bottom of the page..

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