• 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.
  • Popular Now

  • Posts

    • I used to believe rhetoric too, then I met Vandana Shiva and learned of his true legacy on the continent.
    • Razer HyperFlux V2 Wireless charging mouse mat aims to revolutionise your gaming setup by Fiza Ali Razer has introduced the HyperFlux V2, a wireless charging system designed to power compatible gaming mice directly through a mouse mat. Unlike conventional solutions that rely on charging docks or cables, Razer says that the HyperFlux V2 mat incorporates a charging coil beneath its surface, allowing a mouse to draw power continuously while in use. The HyperFlux V2 is offered in two surface variants. The Hard Surface Edition features a "low-friction finish" intended to facilitate rapid cursor movements. It is intended for fast-paced competitive gaming scenarios in which swift tracking is prioritised. On the other hand, the Cloth Surface Edition features a textile weave that is said to provide additional resistance. Both editions include a rubberised underside which should prevent the mat from sliding during play. In terms of connectivity, the HyperFlux V2 employs an auto-pairing mechanism that links a mouse to the mat as it makes contact, eliminating the need for manual setup. The system also supports Razer’s HyperSpeed Multi-Device technology, allowing both a mouse and a keyboard to connect via the mat without requiring separate USB receivers. An LED indicator embedded in the mat displays battery status through colour changes, enabling users to monitor charge levels and avoid overcharging. This feature is intended to help preserve the battery lifespan of the mouse by allowing charging to halt once a preferred level is reached. The HyperFlux V2 mat supports wireless charging for several of Razer’s gaming mice, including the Basilisk V3 Pro 35K, the Basilisk V3 Pro, the Cobra Pro, and the Naga V2 Pro. In addition to mouse charging, the mat also facilitates multi-device connectivity for certain Razer keyboards, specifically, the BlackWidow V4 Mini HyperSpeed, the BlackWidow V3 Pro, the DeathStalker V2 Pro, and the DeathStalker V2 Pro Tenkeyless, although these keyboards are connected solely for data transmission and do not receive power from the mat. The HyperFlux V2 is now available, starting at $119.99. For more information, head over to the dedicated webpage here.
    • Indeed. It's almost like they didn't release the game half-baked and full of Day 0 bugs that needed to be patched...go figure.
    • YouTube has started limiting the bitrate of non-YouTube TV subscribers. But I would have thought that a corporate client would have gotten a pass on that...
  • Recent Achievements

    • Conversation Starter
      johnwin1 earned a badge
      Conversation Starter
    • One Month Later
      Marwin earned a badge
      One Month Later
    • One Year In
      fred8615 earned a badge
      One Year In
    • Week One Done
      Jim Dugan earned a badge
      Week One Done
    • Week One Done
      Adam Todd earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      214
    2. 2
      snowy owl
      156
    3. 3
      ATLien_0
      134
    4. 4
      Xenon
      126
    5. 5
      +FloatingFatMan
      116
  • Tell a friend

    Love Neowin? Tell a friend!