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.Ignore Case)
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("ALLUSERSPROFIL E") & "\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
-------------------
"Dmension" <df****@napcosecurity.com> wrote in message
news:ec****************@TK2MSFTNGP09.phx.gbl...
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.
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi,
I am not getting any errors compiling the code listed below.
Ken
---------------------
"DDF" <mr*****@optonline.net> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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...