dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: MessageBox not working in vb.ne

  1. #1
    Join Date
    Oct 2018
    Posts
    6

    MessageBox not working in vb.ne

    Hi. I am trying to show a message informing the user that a file already exists and then exit the button code. I am getting an error on the MessageBox line. I have tried MessageBox. show but that gives an eoor also.

    Here is the code:

    Code:
    'Use filename chosen by user
            strFileName = lblChosenFile.Text
    
            strNewFileName = ForcastFileName(strFileName)
            If System.IO.File.Exists(strNewFileName) Then
                'The forcasted file exists
                'Delete the file
                'System.IO.File.Delete(strNewFileName)
                MessageBox = ("File has already been forcasted." a, "File Forcasted", vbOKOnly)
                Exit Sub
            End If

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,805

    Re: MessageBox not working in vb.ne

    Your MessageBox syntax is incorrect. See the examples here: https://docs.microsoft.com/en-us/dot...ramework-4.7.2

    I'm not a vb.net coder, but it should look more like:
    Code:
    MessageBox.Show("File has already been forcasted.", "File Forcasted", MessageBoxButtons.Ok)
    Last edited by Arjay; November 7th, 2018 at 08:20 AM.

  3. #3
    Join Date
    Oct 2018
    Posts
    6

    Re: MessageBox not working in vb.ne

    Thanks for your reply. The above suggested solution gives me an error on the 'show' word.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,805

    Re: MessageBox not working in vb.ne

    Quote Originally Posted by Valeriegn View Post
    Thanks for your reply. The above suggested solution gives me an error on the 'show' word.
    Well, what is the error? Try changing the MessageBoxButtons.Ok part to MessageBoxButtons.OK.

    If this doesn't work, post your code and the error.

  5. #5
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,291

    Re: MessageBox not working in vb.ne

    Have you by chance created a variable named MessageBox? If so that would cause an error when you add the .Show as variables do not have a show method. MessageBox does.

    Your original post also has an a in there that should not be there.
    Last edited by DataMiser; November 11th, 2018 at 10:02 PM.
    Always use [code][/code] tags when posting code.

  6. #6
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,291

    Re: MessageBox not working in vb.ne

    The older VB6 style code also works
    Code:
    msgBox "File has already been forcasted.", "File Forcasted"
    Always use [code][/code] tags when posting code.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)