Link to home
Start Free TrialLog in
Avatar of V Nadeau
V Nadeau

asked on

MessageBox not working in VB.net

Hi. I am trying to show a message box when the user has chosen a file that already exists and then exit the sub. I am getting a red line under the word 'show'. The error says "Overload failed because no accessable 'Show' accepts this number of arguments."

The following is my code:

'Use filename chosen by user
        strFileName = lblChosenFile.Text

        strNewFileName = ForcastFileName(strFileName)
        If System.IO.File.Exists(strNewFileName) Then
            'The forcasted file exists
            MessageBox.Show = ("File has already been forcasted.", "File Forcasted", MessageBoxButtons.OK)
            Exit Sub
        End If

Open in new window


Can someone please help with this, it seems like it should be a simple thing to do and I have tried numerous variations ... what and I doing wrong?

Thanks,
Valerie
Avatar of it_saige
it_saige
Flag of United States of America image

Show is a method, try this instead:
'Use filename chosen by user
strFileName = lblChosenFile.Text

strNewFileName = ForcastFileName(strFileName)
If System.IO.File.Exists(strNewFileName) Then
	'The forcasted file exists
	MessageBox.Show("File has already been forcasted.", "File Forcasted", MessageBoxButtons.OK)
	Exit Sub
End If

Open in new window

-saige-
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial