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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using MsgBox() - Build error 1

Status
Not open for further replies.

josel

Programmer
Joined
Oct 16, 2001
Messages
716
Location
US
Howdy!

My second VP.NET program and yet, another brickwall

Simple program
Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim msg As String
        Dim title As String
        Dim style As MsgBoxStyle
        Dim response As MsgBoxResult
        msg = "Do you want to continue?"   ' Define message.
        style = MsgBoxStyle.DefaultButton2 Or _
           MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
        title = "MsgBox Demonstration"   ' Define title.
        ' Display message.
        response = MsgBox(msg, style, title)
        If response = MsgBoxResult.Yes Then   ' User chose Yes.
            ' Perform some action.
        Else
            ' Perform some other action.
        End If
    End Sub

Why can't I build this code? Do I need to have some DLL installed for this to work? Do I need to patch my .NET?

I started using a very simple
MsgBox("This is a message box ...")

After it failed, I decided to read through help (F1) and even its sample failes (pasted above).

When I installed .NET I ran the "Prerequiste ..." option to make sure all was there and made a full install. If there is a chance I left something out, I am willing and ready to reinstall.

Thank you all in advance.


Jose Lerebours

KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
You should probrably try using the .Net version of msgbox.

Messagebox.Show("Message")

It's very similar to msgbox, but it's all managed code and doesn't use the VB6 library.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
i think you will need to import microsoft.visualbasic for msgbox


Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
and probably add a reference to the microsoft.visualbasic.dll

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Well, MessageBox.Show works OK but, I am now able to use MsgBox( ... ) in a different program but not on this simpler version.

I did notice that when I hover the mouse over MsgBox(...) a tool-tip shows 'MsgBox' is a namespace, and so is not a valid expression.

In the second program (where it works fine), when I hover over MsgBox(...), I get a tool-tip that is more descriptive of the syntax for MsgBox() the function itself.

I don't get it. Both programs were created as VB Window application. The one distinct difference between the two is that the working version uses MsgBox() within if statements where the non-working does not.

Oh, thanks for the MessageBox.Show() ...

Regards;


Jose Lerebours


KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Check the references, msgbox is in the old microsoft.visualbasic namespace (I think... might want to double check that) If that dll is not included in your references, you won't be able to access the msgbox command.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Does everybody just ignore me.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
chrissie1,

Not at all ... I just found it interesting that it worked on one program and not in the other ... Funny enogth, I don't even know where to nor how to check for references and much less add anything to it. :)

Well, I guess it is learning time so I will learn.

Regards;


Jose Lerebours


PS: When I wrote the working sample, there were no specific steps given to add anything to the references. It simply has a couple more controls (text control, label control and a button - that's all).





KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
If you look in the solution explorer, immediately under the project you should see a greyish folder called "References" open that and look for Microsoft.VisualBasic

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Both programs, working and non-working program have the same list under - References

System, System.Data, System.Drawing, System.Windows.Forms and System.XML

I have a feeling that this is going to torment me for a while but I will not let it discourage me from Mastering VP .NET (no punt intended) :)

Thanks;


Jose Lerebours



KNOWLEDGE: Something you can give away endlessly and gain more of it in the process! - Jose Lerebours
 
Interesting. I'm tired and sickly at the moment, but it could be the default reference search locations. It's burried some place in the project properties as to what folders the app will look in by default for libraries. It could be set to a different directory on one project that doesn't have the microsoft.visualbasic lib included. Easiest fix though would be to add a reference to that library. I'm not sure if it's considered a .Net lib or if it's in the COM list.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
It's in the GAC and it's in the .net lib you just have to add it. click on add reference and search in the list for microsoft.visualbasic.

and then you will have to add imports microsoft.visualbasic to the top of your class.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top