Results 1 to 8 of 8

Thread: Returning user here, what have I forgot?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2024
    Posts
    2

    Returning user here, what have I forgot?

    I used Visual Studio 2008 years ago, and did some programming with VB Winforms back then. However, I'm trying to re-introduce myself to VS and VB. But I just installed VS Community 2022, and put a button on the default form, double clicked that button to generate the onClick event, and then put in a MsgBox.show("text here"), and it fails every time.

    I know I am asking a really idiotic question, but I have searched to no avail, I've tried following VS tutorials on YouTube, and I don't see anything I should have to do to get the MsgBox to display the text?!?

    Entore code from the Form1.vb:
    Code:
    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            MsgBox.Show("This is first button")
        End Sub
    End Class
    Error shown in the solution error tab:
    Severity Code Description Project File Line Suppression State Details
    Error (active) BC30455 Argument not specified for parameter 'Prompt' of 'Public Overloads Function MsgBox(Prompt As Object, [Buttons As MsgBoxStyle = ApplicationModal], [Title As Object = Nothing]) As MsgBoxResult'. WinFormsApp6 C:\Users\mwyckoff\source\repos\WinFormsApp6\Form1.vb 3

    What am I missing?
    Last edited by dday9; Jul 26th, 2024 at 11:23 AM.

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,961

    Re: Returning user here, what have I forgot?

    MsgBox is the legacy VB6 holdover and it is a function. MessageBox is the .NET equivalent and is a class with the static Show method.

    So if you use MsgBox:
    Code:
    MsgBox("This is first button")
    Or if you use MessageBox:
    Code:
    MessageBox.Show("This is first button")
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2024
    Posts
    2

    Re: Returning user here, what have I forgot?

    Thank you!

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

    Re: Returning user here, what have I forgot?

    The first thing you're missing is Option Strict On. The code you have wouldn't compile with that set and you'd be told that there's no such method. Set it On in the project properties and also set it On in the VS options, so it will be On by default for all future projects.
    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

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,804

    Re: Returning user here, what have I forgot?

    Is this a .Net Core project or a .Net Framework?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,659

    Re: Returning user here, what have I forgot?

    Quote Originally Posted by dbasnett View Post
    Is this a .Net Core project or a .Net Framework?
    Why is that relevant?

  7. #7
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,804

    Re: Returning user here, what have I forgot?

    Quote Originally Posted by .paul. View Post
    Why is that relevant?
    Maybe not for this but I've noticed some changes in signatures depending on this, probably due to standard imports. Seems messagebox was one I spent time chasing. Regardless, knowing the answer to my inquiry can't hurt.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,659

    Re: Returning user here, what have I forgot?

    Quote Originally Posted by dbasnett View Post
    Maybe not for this but I've noticed some changes in signatures depending on this, probably due to standard imports. Seems messagebox was one I spent time chasing. Regardless, knowing the answer to my inquiry can't hurt.

    Ok. I was genuinely interested in a coding way… I don’t know whether .Net Core is different there too.

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