Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox() throws exception

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
568
US
Colleagues,
I've never seen anything like this! This is what system throws

2022_12_16_11_20_Common_Subs_Functions_Debugging_MS_VS_2019_ovkjtp.jpg


which is totally untrue, here's the code (from the line #1 on):

Code:
Imports System
Imports System.Net
Imports System.String
Imports System.IO
Imports System.Windows.Forms
Imports System.Threading
Imports System.Net.Mail
Imports System.Windows
Imports Microsoft.VisualBasic
Imports Microsoft.VisualBasic.FileIO
'====================================================================================================================================
Module Common_Subs_Functions
'====================================================================================================================================
Public Sub Main()
'====================================================================================================================================
' Purpose       : Test the functions and procedures of the Common_Functions class.
' Description   : N/A.
' Parameters	: N/A.
' Returns	: N/A.
' Side effects  : N/A.
' Notes         : 1. Non-specific.
'                 2. Complies with .NET Framework ver. X.X and higher.
' Author        : Ilya I. Rabyy
' Revisions     : by Ilya on 2022-12-15 - started 1st draft.
'====================================================================================================================================
' Testing WaitNSeconds

For I As Int16 = 0 To 10
	MsgBox(I.ToString() & " seconds elapsed")
	WaitNSeconds(5)
Next

End Sub
'====================================================================================================================================

WaitNSeconds() is the procedure I have programmed and tried to test.

IOW, it looks like the VS (2019) doesn't "see" System.Windows.Forms when I have it as Windows Application in the Project's properties, and all the needed components are Imported.

What am I doing wrong?
Please advise!
TIA!


Regards,

Ilya
 
Shouldn't you use:
Code:
MessageBox.Show(I.ToString() & " seconds elapsed")
[ponder]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Well, Andy has a point: MessageBox is the component in System.Windows.Forms; msgbox is in the Microsoft.VisualBasic namespace (as the documention you link to states)

So something odd is going on.

Your code (with an added End Module (and commenting out the WaitNSeconds line) works 100% as expected here (as long as I rename Sub Main). Can you confirm exactly what type of project you are creating?
 
StrongM said:
works 100% as expected here (as long as I rename Sub Main)

Rename how/to what?
Please clarify.

Regards,

Ilya
 
Oh, I have a test application into which I drop people's example code. It already has a Sub Main, so I have to rename YOUR Sub Main. You should not have to, though.
 
StrongM said:
It already has a Sub Main, so I have to rename YOUR Sub Main. You should not have to, though.
Got it, thanks!

Still can't figure out what's going on.
Here's another weird thing:

2022_12_19_11_12_MsgBox_MS_VS_2019_l7m8ky.jpg


Now I am at total loss!

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top