-
Jul 26th, 2024, 11:07 AM
#1
Thread Starter
New Member
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.
-
Jul 26th, 2024, 11:25 AM
#2
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")
-
Jul 26th, 2024, 11:32 AM
#3
Thread Starter
New Member
Re: Returning user here, what have I forgot?
-
Jul 26th, 2024, 12:01 PM
#4
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.
-
Jul 26th, 2024, 12:57 PM
#5
Re: Returning user here, what have I forgot?
Is this a .Net Core project or a .Net Framework?
-
Jul 26th, 2024, 03:02 PM
#6
Re: Returning user here, what have I forgot?
Originally Posted by dbasnett
Is this a .Net Core project or a .Net Framework?
Why is that relevant?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 27th, 2024, 09:27 AM
#7
Re: Returning user here, what have I forgot?
Originally Posted by .paul.
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.
-
Jul 27th, 2024, 11:22 AM
#8
Re: Returning user here, what have I forgot?
Originally Posted by dbasnett
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.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|