VB 2008 Error Message

Statement is not valid in a namspace

Page 1 of 1

4 Replies - 2623 Views - Last Post: 23 September 2009 - 10:32 AM Rate Topic: -----

#1 Jrdpa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 16-February 09

VB 2008 Error Message

Posted 21 September 2009 - 03:44 PM

Can someone tell me what this error message in VB 2008 Express Edition means? This is my first VB assignment so I am not familiar with all of the error messages yet.

Statement is not valid in a namspace


VB is putting out this error for every first line of code that it wrote (Private Sub...). I didn't touch that code though. The subsections I did delete (for when I changed things) were empty, I hadn't put any code in yet.

Private Sub btnCalcMpg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
	'Calculates the MPG
	Dim intCapacity As Integer
	Dim intDrive As Integer
	Dim intMpg As Integer
	intMpg = intDrive \ intCapacity
End Sub

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
	'Clears the form
	txtCapacity.Clear()
	txtDrive.Clear()
	txtMpg.Clear()

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
	'End the application by clicking the Exit button.
	Me.Close()
End Sub



Thanks,

JRDPA

Is This A Good Question/Topic? 0
  • +

Replies To: VB 2008 Error Message

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: VB 2008 Error Message

Posted 21 September 2009 - 03:57 PM

VB 2008 is not VB6. Moved to VB.NET :)

Post the entire code file, it sounds like you may have thos inside the Namespace and outside the class itself.
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: VB 2008 Error Message

Posted 21 September 2009 - 04:03 PM

To clarify what PsychoCoder means
'
' Your Subs are here
'
Public Class Form1

End Class

' or Your Subs are here (or both) 


Was This Post Helpful? 0
  • +
  • -

#4 Jrdpa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 16-February 09

Re: VB 2008 Error Message

Posted 22 September 2009 - 11:45 AM

View PostPsychoCoder, on 21 Sep, 2009 - 02:57 PM, said:

VB 2008 is not VB6. Moved to VB.NET :)

Post the entire code file, it sounds like you may have thos inside the Namespace and outside the class itself.


I didn't think it was .NET either since we aren't working with that in class so wasn't sure where to put this.

JRDPA

View PostAdamSpeight2008, on 21 Sep, 2009 - 03:03 PM, said:

To clarify what PsychoCoder means
'
' Your Subs are here
'
Public Class Form1

End Class

' or Your Subs are here (or both) 




Here is what I have though I hadn't touched any of that, just what I showed you.

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
	Inherits System.Windows.Forms.Form

	'Form overrides dispose to clean up the component list.
	<System.Diagnostics.DebuggerNonUserCode()> _
	Protected Overrides Sub Dispose(ByVal disposing As Boolean)
		Try
			If disposing AndAlso components IsNot Nothing Then
				components.Dispose()
			End If
		Finally
			MyBase.Dispose(disposing)
		End Try
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> _
	Private Sub InitializeComponent()
		Me.Label1 = New System.Windows.Forms.Label
		Me.txtCapacity = New System.Windows.Forms.TextBox
		Me.Label2 = New System.Windows.Forms.Label
		Me.txtDrive = New System.Windows.Forms.TextBox
		Me.Label3 = New System.Windows.Forms.Label
		Me.txtMpg = New System.Windows.Forms.TextBox
		Me.btnCalcMpg = New System.Windows.Forms.Button
		Me.btnClear = New System.Windows.Forms.Button
		Me.btnExit = New System.Windows.Forms.Button
		Me.SuspendLayout()
		'
		'Label1
		'
		Me.Label1.AutoSize = True
		Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label1.Location = New System.Drawing.Point(29, 32)
		Me.Label1.Name = "Label1"
		Me.Label1.Size = New System.Drawing.Size(121, 13)
		Me.Label1.TabIndex = 0
		Me.Label1.Text = "Fuel Tank Capacity:"
		'
		'txtCapacity
		'
		Me.txtCapacity.Location = New System.Drawing.Point(200, 32)
		Me.txtCapacity.Name = "txtCapacity"
		Me.txtCapacity.Size = New System.Drawing.Size(100, 20)
		Me.txtCapacity.TabIndex = 1
		'
		'Label2
		'
		Me.Label2.AutoSize = True
		Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label2.Location = New System.Drawing.Point(29, 91)
		Me.Label2.Name = "Label2"
		Me.Label2.Size = New System.Drawing.Size(145, 39)
		Me.Label2.TabIndex = 2
		Me.Label2.Text = "Number of miles the car " & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "can be driven on a full " & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "tank:"
		'
		'txtDrive
		'
		Me.txtDrive.Location = New System.Drawing.Point(200, 91)
		Me.txtDrive.Name = "txtDrive"
		Me.txtDrive.Size = New System.Drawing.Size(100, 20)
		Me.txtDrive.TabIndex = 3
		'
		'Label3
		'
		Me.Label3.AutoSize = True
		Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label3.Location = New System.Drawing.Point(34, 162)
		Me.Label3.Name = "Label3"
		Me.Label3.Size = New System.Drawing.Size(99, 13)
		Me.Label3.TabIndex = 4
		Me.Label3.Text = "Miles Per Gallon"
		'
		'txtMpg
		'
		Me.txtMpg.Location = New System.Drawing.Point(200, 155)
		Me.txtMpg.Name = "txtMpg"
		Me.txtMpg.Size = New System.Drawing.Size(100, 20)
		Me.txtMpg.TabIndex = 5
		'
		'btnCalcMpg
		'
		Me.btnCalcMpg.Location = New System.Drawing.Point(34, 213)
		Me.btnCalcMpg.Name = "btnCalcMpg"
		Me.btnCalcMpg.Size = New System.Drawing.Size(75, 38)
		Me.btnCalcMpg.TabIndex = 6
		Me.btnCalcMpg.Text = "Caclculate MPG"
		Me.btnCalcMpg.UseVisualStyleBackColor = True
		'
		'btnClear
		'
		Me.btnClear.Location = New System.Drawing.Point(129, 213)
		Me.btnClear.Name = "btnClear"
		Me.btnClear.Size = New System.Drawing.Size(75, 38)
		Me.btnClear.TabIndex = 7
		Me.btnClear.Text = "Clear"
		Me.btnClear.UseVisualStyleBackColor = True
		'
		'btnExit
		'
		Me.btnExit.Location = New System.Drawing.Point(225, 213)
		Me.btnExit.Name = "btnExit"
		Me.btnExit.Size = New System.Drawing.Size(75, 38)
		Me.btnExit.TabIndex = 8
		Me.btnExit.Text = "E&xit"
		Me.btnExit.UseVisualStyleBackColor = True
		'
		'Form1
		'
		Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.ClientSize = New System.Drawing.Size(367, 273)
		Me.Controls.Add(Me.btnExit)
		Me.Controls.Add(Me.btnClear)
		Me.Controls.Add(Me.btnCalcMpg)
		Me.Controls.Add(Me.txtMpg)
		Me.Controls.Add(Me.Label3)
		Me.Controls.Add(Me.txtDrive)
		Me.Controls.Add(Me.Label2)
		Me.Controls.Add(Me.txtCapacity)
		Me.Controls.Add(Me.Label1)
		Me.Name = "Form1"
		Me.Text = "Miles Per Gallon Calculator by Robin Davidson"
		Me.ResumeLayout(False)
		Me.PerformLayout()

	End Sub
	Friend WithEvents Label1 As System.Windows.Forms.Label
	Friend WithEvents txtCapacity As System.Windows.Forms.TextBox
	Friend WithEvents Label2 As System.Windows.Forms.Label
	Friend WithEvents txtDrive As System.Windows.Forms.TextBox
	Friend WithEvents Label3 As System.Windows.Forms.Label
	Friend WithEvents txtMpg As System.Windows.Forms.TextBox
	Friend WithEvents btnCalcMpg As System.Windows.Forms.Button
	Friend WithEvents btnClear As System.Windows.Forms.Button
	Friend WithEvents btnExit As System.Windows.Forms.Button

  
	Private Sub txtCapacity_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCapacity.TextChanged

	End Sub
End Class


Was This Post Helpful? 0
  • +
  • -

#5 Jrdpa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 38
  • Joined: 16-February 09

Re: VB 2008 Error Message

Posted 23 September 2009 - 10:32 AM

View PostJrdpa, on 22 Sep, 2009 - 10:45 AM, said:

View PostPsychoCoder, on 21 Sep, 2009 - 02:57 PM, said:

VB 2008 is not VB6. Moved to VB.NET :)

Post the entire code file, it sounds like you may have thos inside the Namespace and outside the class itself.


I didn't think it was .NET either since we aren't working with that in class so wasn't sure where to put this.

JRDPA

View PostAdamSpeight2008, on 21 Sep, 2009 - 03:03 PM, said:

To clarify what PsychoCoder means
'
' Your Subs are here
'
Public Class Form1

End Class

' or Your Subs are here (or both) 




Here is what I have though I hadn't touched any of that, just what I showed you.

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
	Inherits System.Windows.Forms.Form

	'Form overrides dispose to clean up the component list.
	<System.Diagnostics.DebuggerNonUserCode()> _
	Protected Overrides Sub Dispose(ByVal disposing As Boolean)
		Try
			If disposing AndAlso components IsNot Nothing Then
				components.Dispose()
			End If
		Finally
			MyBase.Dispose(disposing)
		End Try
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> _
	Private Sub InitializeComponent()
		Me.Label1 = New System.Windows.Forms.Label
		Me.txtCapacity = New System.Windows.Forms.TextBox
		Me.Label2 = New System.Windows.Forms.Label
		Me.txtDrive = New System.Windows.Forms.TextBox
		Me.Label3 = New System.Windows.Forms.Label
		Me.txtMpg = New System.Windows.Forms.TextBox
		Me.btnCalcMpg = New System.Windows.Forms.Button
		Me.btnClear = New System.Windows.Forms.Button
		Me.btnExit = New System.Windows.Forms.Button
		Me.SuspendLayout()
		'
		'Label1
		'
		Me.Label1.AutoSize = True
		Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label1.Location = New System.Drawing.Point(29, 32)
		Me.Label1.Name = "Label1"
		Me.Label1.Size = New System.Drawing.Size(121, 13)
		Me.Label1.TabIndex = 0
		Me.Label1.Text = "Fuel Tank Capacity:"
		'
		'txtCapacity
		'
		Me.txtCapacity.Location = New System.Drawing.Point(200, 32)
		Me.txtCapacity.Name = "txtCapacity"
		Me.txtCapacity.Size = New System.Drawing.Size(100, 20)
		Me.txtCapacity.TabIndex = 1
		'
		'Label2
		'
		Me.Label2.AutoSize = True
		Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label2.Location = New System.Drawing.Point(29, 91)
		Me.Label2.Name = "Label2"
		Me.Label2.Size = New System.Drawing.Size(145, 39)
		Me.Label2.TabIndex = 2
		Me.Label2.Text = "Number of miles the car " & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "can be driven on a full " & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "tank:"
		'
		'txtDrive
		'
		Me.txtDrive.Location = New System.Drawing.Point(200, 91)
		Me.txtDrive.Name = "txtDrive"
		Me.txtDrive.Size = New System.Drawing.Size(100, 20)
		Me.txtDrive.TabIndex = 3
		'
		'Label3
		'
		Me.Label3.AutoSize = True
		Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
		Me.Label3.Location = New System.Drawing.Point(34, 162)
		Me.Label3.Name = "Label3"
		Me.Label3.Size = New System.Drawing.Size(99, 13)
		Me.Label3.TabIndex = 4
		Me.Label3.Text = "Miles Per Gallon"
		'
		'txtMpg
		'
		Me.txtMpg.Location = New System.Drawing.Point(200, 155)
		Me.txtMpg.Name = "txtMpg"
		Me.txtMpg.Size = New System.Drawing.Size(100, 20)
		Me.txtMpg.TabIndex = 5
		'
		'btnCalcMpg
		'
		Me.btnCalcMpg.Location = New System.Drawing.Point(34, 213)
		Me.btnCalcMpg.Name = "btnCalcMpg"
		Me.btnCalcMpg.Size = New System.Drawing.Size(75, 38)
		Me.btnCalcMpg.TabIndex = 6
		Me.btnCalcMpg.Text = "Caclculate MPG"
		Me.btnCalcMpg.UseVisualStyleBackColor = True
		'
		'btnClear
		'
		Me.btnClear.Location = New System.Drawing.Point(129, 213)
		Me.btnClear.Name = "btnClear"
		Me.btnClear.Size = New System.Drawing.Size(75, 38)
		Me.btnClear.TabIndex = 7
		Me.btnClear.Text = "Clear"
		Me.btnClear.UseVisualStyleBackColor = True
		'
		'btnExit
		'
		Me.btnExit.Location = New System.Drawing.Point(225, 213)
		Me.btnExit.Name = "btnExit"
		Me.btnExit.Size = New System.Drawing.Size(75, 38)
		Me.btnExit.TabIndex = 8
		Me.btnExit.Text = "E&xit"
		Me.btnExit.UseVisualStyleBackColor = True
		'
		'Form1
		'
		Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.ClientSize = New System.Drawing.Size(367, 273)
		Me.Controls.Add(Me.btnExit)
		Me.Controls.Add(Me.btnClear)
		Me.Controls.Add(Me.btnCalcMpg)
		Me.Controls.Add(Me.txtMpg)
		Me.Controls.Add(Me.Label3)
		Me.Controls.Add(Me.txtDrive)
		Me.Controls.Add(Me.Label2)
		Me.Controls.Add(Me.txtCapacity)
		Me.Controls.Add(Me.Label1)
		Me.Name = "Form1"
		Me.Text = "Miles Per Gallon Calculator by Robin Davidson"
		Me.ResumeLayout(False)
		Me.PerformLayout()

	End Sub
	Friend WithEvents Label1 As System.Windows.Forms.Label
	Friend WithEvents txtCapacity As System.Windows.Forms.TextBox
	Friend WithEvents Label2 As System.Windows.Forms.Label
	Friend WithEvents txtDrive As System.Windows.Forms.TextBox
	Friend WithEvents Label3 As System.Windows.Forms.Label
	Friend WithEvents txtMpg As System.Windows.Forms.TextBox
	Friend WithEvents btnCalcMpg As System.Windows.Forms.Button
	Friend WithEvents btnClear As System.Windows.Forms.Button
	Friend WithEvents btnExit As System.Windows.Forms.Button

  
	Private Sub txtCapacity_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCapacity.TextChanged

	End Sub
End Class



Since I can't seem to get the design view back, I guess I will have to start over. :angry: I'm so aggravated I can't figure it out. I right click and all I see is Code View, which is what I'm looking at! I opened every file I could too.

JRDPA

This post has been edited by Jrdpa: 23 September 2009 - 10:33 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1