Not valid namespace

  • Thread starter Thread starter DDF
  • Start date Start date
D

DDF

I took this snippet from a book I foudn online. Public Class Demo
Public Structure ValueDemo
Public X As Integer
End Structure
Public Class RefDemo
Public Y As Integer
End Class
Public Sub InstantiateTypes()
' This line declares a ValueDemo variable
Dim DemoStructure As ValueDemo
' This line creates an instance of ValueDemo on the stack
DemoStructure = New ValueDemo()
' The variable is ready to receive data.
DemoStructure.X = 15
' This line declares a RefDemo variable, but doesn't
' create an instance of the class
Dim DemoClass As RefDemo
' This line actually creates the object
DemoClass = New RefDemo()
' And you can now assign value to its members
DemoClass.Y = 15
End Sub
End ClassWhen trying to compile The ide si telling me that this is not a valid namespace. Can anyone help...Thanks...
 
Hi,

I am not getting any errors compiling the code listed below.

Ken
---------------------

I took this snippet from a book I foudn online.
Public Class Demo
Public Structure ValueDemo
Public X As Integer
End Structure
Public Class RefDemo
Public Y As Integer
End Class
Public Sub InstantiateTypes()
' This line declares a ValueDemo variable
Dim DemoStructure As ValueDemo
' This line creates an instance of ValueDemo on the stack
DemoStructure = New ValueDemo()
' The variable is ready to receive data.
DemoStructure.X = 15
' This line declares a RefDemo variable, but doesn't
' create an instance of the class
Dim DemoClass As RefDemo
' This line actually creates the object
DemoClass = New RefDemo()
' And you can now assign value to its members
DemoClass.Y = 15
End Sub
End Class
When trying to compile The ide si telling me that this is not a valid
namespace. Can anyone help...

Thanks...
 
Did you create a windows app or was is a console windows app? I added this
code to the form load of a form and was not able to get any further because
the instantiatetype() was giving me an error. I was going to make some
modes to pop up message boxs.
 
Hi,

A windows form app.

Public Class Form1

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

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

Dim regTest As New System.Text.RegularExpressions.Regex("tHe",
System.Text.RegularExpressions.RegexOptions.IgnoreCase)

Dim strCheck As String = "This is the test string. I the regex works."

Dim m As System.Text.RegularExpressions.MatchCollection

m = regTest.Matches(strCheck)

Me.Text = m.Count.ToString

Dim strDate As String = "2005-01-10"

Dim dt As Date = Date.ParseExact(strDate, "yyyy-mm-dd", New
Globalization.CultureInfo("en-US"))

Me.Text = dt.ToShortDateString





Dim environmentVariables As IDictionary =
Environment.GetEnvironmentVariables()

Dim de As DictionaryEntry

For Each de In environmentVariables

Trace.WriteLine(String.Format(" {0} = {1}", de.Key, de.Value))

Next de

Me.Text = Environment.GetEnvironmentVariable("ALLUSERSPROFILE") & "\Start
Menu"

Dim d As New Demo

d.InstantiateTypes()

End Sub

End Class



Public Class Demo

Public Structure ValueDemo

Public X As Integer

End Structure

Public Class RefDemo

Public Y As Integer

End Class

Public Sub InstantiateTypes()

' This line declares a ValueDemo variable

Dim DemoStructure As ValueDemo

' This line creates an instance of ValueDemo on the stack

DemoStructure = New ValueDemo

' The variable is ready to receive data.

DemoStructure.X = 15

' This line declares a RefDemo variable, but doesn't

' create an instance of the class

Dim DemoClass As RefDemo

' This line actually creates the object

DemoClass = New RefDemo

' And you can now assign value to its members

DemoClass.Y = 15

End Sub

End Class



Ken

-------------------


Did you create a windows app or was is a console windows app? I added this
code to the form load of a form and was not able to get any further because
the instantiatetype() was giving me an error. I was going to make some
modes to pop up message boxs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top