• 0

Problem w/ Immediate Window in VB.NET


Question

Hi guys,

I'm moving from VB6 to VS.NET 2010, and I'm getting the hang of it but I am having a hell of a time trying to use the Immediate window like I used to in VB6.

For example, when I typed in:

MsgBox "test"

I would get a msgbox with Text in it.

If I try the same in VB.NET:

MsgBox("test")

all I get is this:

'MsgBox' is not declared. It may be inaccessible due to its protection level.

Why can't this thing just work the way it used to, or am i missing something?

Thanks!

Link to comment
https://www.neowin.net/forum/topic/1023628-problem-w-immediate-window-in-vbnet/
Share on other sites

5 answers to this question

Recommended Posts

  • 0

My VB is rusty, but if I recall you may need to import the Microsoft.VisualBasic namespace for the older MsgBox function. Should be imported by default in a WinForm app, will need to reference it manually in a console app I believe. Personally, you might want to consider getting used to the MessageBox class instead though.

  • 0
  On 07/09/2011 at 11:27, Jen Smith said:

My VB is rusty, but if I recall you may need to import the Microsoft.VisualBasic namespace for the older MsgBox function. Should be imported by default in a WinForm app, will need to reference it manually in a console app I believe. Personally, you might want to consider getting used to the MessageBox class instead though.

Jen, your on the ball. I tried the Microsoft.VisualBasic.MsgBox("hello") function, and it worked. If I try just MessageBox class, it gives the error again...

This is what I am after however:

Microsoft.VisualBasic.MsgBox(My.Computer.Info.OSVersion)

so I can see that so I can write code based on total number of dots.

<sigh>

I really wish MS hadn't messed with VB...

  • 0

Don't use the old VB MsgBox function, instead use the .NET MessageBox class and its static Show method.

Imports System.Windows.Forms

MessageBox.Show("Hellold.")

The reason why your code didn't work is because you need to import the proper namespaces. An Imports statement would have fixed your code, but it's better to make use of the 'real' .NET classes. ;)

  • 0
  On 07/09/2011 at 11:42, Mr. Black said:
<sigh>I really wish MS hadn't messed with VB...

I'm more of a C++/C# coder, but once you get the hang of the framework VB is a lot better than it used to be, be it in features or in the language itself. If anything read over MSDN, there's a crazy amount of documentation and help material to go over. Still should consider getting used to using the proper MessageBox class though. While you're at it, poke around the various namespaces in the object browser, there's an absurd amount of functionality built into the platform right out of the box.

Just to save yourself a bit of typing, you can import the namespace so you don't have to constantly name the whole method every time you use it. Example:

Imports Microsoft.VisualBasic

Module Module1

    Sub Main()
        MsgBox("OS Version: " + My.Computer.Info.OSVersion)
    End Sub

End Module

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • HopToDesk 1.44.2 by Razvan Serea HopToDesk aims to improve the user experience by providing a free, easy-to-use, and secure remote desktop solution for all major device types including Windows PC, Mac, Linux, Android, Chrome Books, iOS, and even Raspberry Pi devices. HopToDesk empowers you to connect, control, and collaborate with ease. Whether you're providing IT support, managing remote teams, or accessing your own devices from anywhere, HopToDesk offers a reliable and secure solution. HopToDesk does not and cannot monitor user activity as the application uses end-to-end encryption for all traffic, and does not make a distinction between personal and business use (both are allowed). Additionally, HopToDesk includes many of the main features of common remote desktop solutions such as Unattended Access, File Transfer, Live Chat, Wake-On-LAN, 2FA, Direct IP access, a Recent Session and Favorite list, and is available in over 20 languages. HopToDesk can run in portable mode or installed on desktop operating systems. Installation is optional, and will install the HopToDesk service which runs in the background and listens for incoming connections, allowing the device to be accessible at all times. Why Choose HopToDesk? Completely Free: Enjoy full access for both personal and commercial use—no hidden fees or limitations. End-to-End Encryption: All communications, including screen sharing, file transfers, and chats, are protected with robust encryption. Open Source: Contribute to and benefit from a transparent and community-driven project. No Account Required: Connect instantly without the need for sign-ups or subscriptions. Core Features Remote Control & Screen Sharing: Effortlessly access and manage remote devices. File Transfer: Securely send and receive files with drag-and-drop simplicity. Live Chat: Communicate in real-time during sessions. Multi-Monitor Support: Navigate multiple screens with ease. Clipboard Synchronization: Copy and paste seamlessly across devices. Wake-on-LAN: Power on remote systems remotely. Session Recording: Document sessions for future reference. Two-Factor Authentication: Enhance security with an additional verification layer. Custom Branding: Personalize your remote sessions with custom avatars. Unattended Access: Connect to devices without requiring user intervention. Network Customization: Adjust settings like TURN relays and signaling servers to suit your environment. Centralized Device Management Utilize the HopToDesk Dashboard to: Monitor device status in real-time. Generate invite links for easy device integration. Customize network settings and synchronize changes effortlessly. Add a personal touch with custom avatars displayed during remote sessions. Download: HopToDesk 64-bit | 8.2 MB (Open Source) Download: HopToDesk 32-bit | 7.0 MB Link: HopToDesk Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Depends, they did have some practice with The Man in the High Castle on occupation force having taken over and focused on USA's subjugation, which is closer to Machine Games Wolfenstien run with the second game in concept. But not to the extent of the batshit insane stuff in the original games before then. We don't have any hints to where in the timeline they will place the TV series. So just pray it doesn't suck and keeps close to the source material to make it more different than the same beats as TMITHC.
    • But it also actually implemented even in some red states in us((
    • Thanks. Then lets use that, instead of wireless charging but then again a lot of people may not know what "inductive charging" is and would need to be educated as to its meaning.
    • I heard that uk already setup an adult content blocker on isp, is that not enough for them?
  • Recent Achievements

    • Dedicated
      EYEREX earned a badge
      Dedicated
    • First Post
      Electronic Person earned a badge
      First Post
    • Week One Done
      CyberCeps666 earned a badge
      Week One Done
    • Very Popular
      d4l3d earned a badge
      Very Popular
    • Dedicated
      Stephen Leibowitz earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      602
    2. 2
      ATLien_0
      232
    3. 3
      Xenon
      159
    4. 4
      neufuse
      131
    5. 5
      +FloatingFatMan
      124
  • Tell a friend

    Love Neowin? Tell a friend!