Avatar of Tom Powers
Tom Powers

asked on 

opendiagog1 generates an error if you hit cancel in vb.net

I use a opendialog control I can upload a picture   my question is when a user click cancel instead of ok for opendialog it bombs out on this line  pic = New Bitmap(OpenFileDialog1.FileName) I am clueless i've tryed a few tricks don't want to use On error resume next if there were just a way to just have nothing happen when user clicks cancel

 Public Sub uploadMLB()

        Dim path As String = "c:\My Pictures\"
        Dim pic As Image
        OpenFileDialog1.ShowDialog()
        pic = New Bitmap(OpenFileDialog1.FileName)
        If Sportscode = "AA" Then
            picnflplayer.Image = pic
            picnflplayer.Visible = True

        Else
            Exit Sub
            btnuploadpic.Text = "Save"
        End If

    End Sub

Open in new window

.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
Tom Powers
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Tom Powers
Tom Powers

ASKER

AndyAinscow: THANK YOU MY FRIEND I WAS BATTLEING IT FOR AN HOUR THEN YOU STEPPED IT SIMPLE BUT EXFFECT THANKS ANDY.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo