Page 1 of 1
error: name 'msgbox not declaired'
Posted: 25 Jun 2009, 21:50
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
Re: error: name 'msgbox not declaired'
Posted: 25 Jun 2009, 22:05
by DarkStar
Well, we're probably going to need snippets of the code in question to help you with the matter.
Re: error: name 'msgbox not declaired'
Posted: 25 Jun 2009, 22:08
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.
Re: error: name 'msgbox not declaired'
Posted: 25 Jun 2009, 22:33
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
Re: error: name 'msgbox not declaired'
Posted: 25 Jun 2009, 23:23
by SykomantiS
did you include the relevant libraries? (C# uses libraries so I'm assuming VB does too)
Re: error: name 'msgbox not declaired'
Posted: 26 Jun 2009, 08:03
by doo_much
*deleted - supposed to be the Afrikaans thread...
Re: error: name 'msgbox not declaired'
Posted: 26 Jun 2009, 08:20
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.
Re: error: name 'msgbox not declaired'
Posted: 26 Jun 2009, 08:33
by c0d3r
afaik vb.net uses
MessageBox.Show("Whatever message you want to show")
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.
Re: error: name 'msgbox not declaired'
Posted: 26 Jun 2009, 08:45
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:(
Re: error: name 'msgbox not declaired'
Posted: 26 Jun 2009, 08:49
by c0d3r
Code: Select all
MessageBox.Show("Whatever message you want to show")
MsgBox is VB6 style. Click
here and read about this.
Re: error: name 'msgbox not declaired'
Posted: 26 Jun 2009, 16:05
by GrimStoner
MsgBox still works in VB.NET 3.5. There is no MsgBox in C# though (there you have to use MessageBox.Show()).
Re: error: name 'msgbox not declaired'
Posted: 30 Jun 2009, 16:32
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.
Re: error: name 'msgbox not declaired'
Posted: 01 Jul 2009, 08:15
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