error: name 'msgbox not declaired'

Get help on programming - C++, Java, Delphi, etc.
Post Reply
geraldhum
Registered User
Posts: 199
Joined: 13 Feb 2009, 12:59

error: name 'msgbox not declaired'

Post by geraldhum »

Hi guys

I am using vb.net in visual studio 2005

Last night everything was going good in my code, this morning when i arrived to work and compiled my application i get error messages for all built in functions in my error window. I checked and the windows.forms reference is there and added.

error: msgbox not declared
error: inputbox not declared

I copied the error codes into Google and nothing come up and I never changed anything.

Regards
Gerald
DarkStar
Registered User
Posts: 2701
Joined: 17 Aug 2004, 02:00
Location: What? You mean you can't see me?
Contact:

Re: error: name 'msgbox not declaired'

Post by DarkStar »

Well, we're probably going to need snippets of the code in question to help you with the matter.
If I can't find a friendship problem...I'll make a friendship problem!
http://www.youtube.com/watch?v=Lxo1qlk6gEI
User avatar
Ron2K
Forum Technical Administrator
Posts: 9050
Joined: 04 Jul 2006, 16:45
Location: Upper Hutt, New Zealand
Contact:

Re: error: name 'msgbox not declaired'

Post by Ron2K »

.NET doesn't have classes called "msgbox" or "inputbox". Either you're referring to the MessageBox and TextBox classes (both in System.Windows.Forms), or you're missing a reference to whatever custom code defines them.

EDIT: Hang on - are those class names, or variable names? If they're variable names, you haven't declared your variables.
Kia kaha, Kia māia, Kia manawanui.
geraldhum
Registered User
Posts: 199
Joined: 13 Feb 2009, 12:59

Re: error: name 'msgbox not declaired'

Post by geraldhum »

Hi

Sorry it's visual basic 2005. Ill post some of the code when i get back to work.

It gives me errors for every inputbox, msgbox and for example my code would look like this.

Code: Select all

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If txtclient.text = "" Then
            MsgBox("Please enter in the clients name", MsgBoxStyle.Information)
        End If
    End Sub
This is my home pc which works ok, the software on my work pc somehow is giving me the errors
SykomantiS
Registered User
Posts: 14085
Joined: 06 Oct 2004, 02:00
Location: Location, Location...
Contact:

Re: error: name 'msgbox not declaired'

Post by SykomantiS »

did you include the relevant libraries? (C# uses libraries so I'm assuming VB does too)
doo_much
Registered User
Posts: 26022
Joined: 13 May 2004, 02:00
Location: Getting there...
Contact:

Re: error: name 'msgbox not declaired'

Post by doo_much »

*deleted - supposed to be the Afrikaans thread... :oops:
MOOD - Thirsty

A surprising amount of modern pseudoscience is coming out of the environmental sector. Perhaps it should not be so surprising given that environmentalism is political rather than scientific.
Timothy Casey
geraldhum
Registered User
Posts: 199
Joined: 13 Feb 2009, 12:59

Re: error: name 'msgbox not declaired'

Post by geraldhum »

I'm here at work and here is a piece of code snippet.

Code: Select all

  'creates the details.txt file
            Dim tw As TextWriter
            tw = File.CreateText(Path & Client & "\" & "Details.txt")
            If File.Exists(Path & Client & "\" & "Details.txt") Then
                tw.WriteLine("Contact No1:" & Space(2) & ContactNo1)
                tw.WriteLine("Contact No2:" & Space(2) & ContactNo2)
                tw.WriteLine("Fax No:" & Space(2) & FaxNo)
                tw.WriteLine("Address:" & Space(2) & Address)
                tw.WriteLine("PO Box:" & Space(2) & POBox)
                tw.Flush()
                tw.Close()
            End If
In visual basic you don't include the relevant libraries, but i have imports the system.windows.forms name space and also added the reference by right clicking the project name and "add reference"

even this "Space" class has suddenly given me error: "space not declaired" and was working fine until i don't know what happend.
c0d3r
Registered User
Posts: 8752
Joined: 18 Jan 2009, 10:24
Location: Istanbul, Turkey

Re: error: name 'msgbox not declaired'

Post by c0d3r »

afaik vb.net uses

MessageBox.Show("Whatever message you want to show")

:scratch:

Code: Select all

tw.WriteLine("Contact No1:" & Space(2) & ContactNo1)
I think you are missing basic references.

Does your code say Imports System.Windows... anywhere at the top before the Class declaration?

Edit: Meh, I reread your post. Idk. Something is out of whack with your code.
а плечьми буйство струйка. Дверь Твоем юдоли. Виновником неразлучен страшиться невинность милосердье сладчайший. Век под вне Оно Нет сия тук. Все вас совоздыхая устремится ком мню возблеснув разверзают лик мой сопрягаешь. Неправды но Ту светлеет Неправых Ни ум смотреть.
geraldhum
Registered User
Posts: 199
Joined: 13 Feb 2009, 12:59

Re: error: name 'msgbox not declaired'

Post by geraldhum »

Hi

Yes i have did imports system.windows.forms at the top.

Here is another piece of the code, as i said it was working fine until i came to work the next morning and just never compiled.

Code: Select all

   Try
            'clears the listview before adding all the items
            Me.ListView1.Clear()

            ' adding all the clients to the list view
            Dim di As DirectoryInfo

            di = New DirectoryInfo("\\192.168.0.1\share josam\josam client profile\" & Me.TreeView1.SelectedNode.Text)

            For Each subdi As DirectoryInfo In di.GetDirectories
                Me.ListView1.Items.Add(subdi.Name, 0)
            Next

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
then again this msgbox is giving me an error. I don't know maybe i just should check my last backup on the visual studio and see what happens, but haven't backed up in a while:(
c0d3r
Registered User
Posts: 8752
Joined: 18 Jan 2009, 10:24
Location: Istanbul, Turkey

Re: error: name 'msgbox not declaired'

Post by c0d3r »

Code: Select all

MessageBox.Show("Whatever message you want to show")
MsgBox is VB6 style. Click here and read about this.
а плечьми буйство струйка. Дверь Твоем юдоли. Виновником неразлучен страшиться невинность милосердье сладчайший. Век под вне Оно Нет сия тук. Все вас совоздыхая устремится ком мню возблеснув разверзают лик мой сопрягаешь. Неправды но Ту светлеет Неправых Ни ум смотреть.
GrimStoner
Registered User
Posts: 716
Joined: 08 Oct 2004, 02:00
Contact:

Re: error: name 'msgbox not declaired'

Post by GrimStoner »

MsgBox still works in VB.NET 3.5. There is no MsgBox in C# though (there you have to use MessageBox.Show()).
Image
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: error: name 'msgbox not declaired'

Post by SBSP »

Have you by any chance had VB6 installed on your home PC?

Try downloading the VB6 run times and install them then try again.
Or change the code so it uses Messagebox instead of Msgbox.

Something must be missing.
geraldhum
Registered User
Posts: 199
Joined: 13 Feb 2009, 12:59

Re: error: name 'msgbox not declaired'

Post by geraldhum »

Thanks for the replies, I went back to check all my added references and i added "microsoft.visualbasic" I suppose that reference is for using vb6 style classes.

Im changing all my msgboxes to MessageBoxes, but im not sure on how to use inputbox, what does vb.net use instead on inputbox

Thanks again

Regards
Gerald
Post Reply