Posted by nicesource on 2009/04/11
Imports System
Imports System.IO
Imports System.Messaging
Public Class MainClass
Shared Sub Main()
Dim mQ As MessageQueue
Dim mes As Message
Dim X As String
Dim br As BinaryReader
If MessageQueue.Exists(".\Private$\HelloWorld") Then
mQ = New MessageQueue(".\Private$\HelloWorld")
Else
Console.WriteLine("Queue doesn't exist.")
Return
End If
Try
mes = mQ.Receive(New TimeSpan(0, 0, 3))
br = New BinaryReader(mes.BodyStream)
X = New String(br.ReadChars(CType(mes.BodyStream.Length, Integer)))
Console.WriteLine("Received Message: {0}", X)
Catch
Console.WriteLine("No Message to Receive.")
End Try
End Sub
End Class
Posted in Network Remote | Leave a Comment »
Posted by nicesource on 2009/04/11
Imports System.Web.Mail
Module Module1
Sub Main()
Dim Smtp As SmtpMail
Smtp.SmtpServer = “Put Your STMP Server Address Here”
Dim Msg As MailMessage = New MailMessage()
Msg.Body = “Demo message from a program”
Msg.From = “fromEmail@SomeSite.com”
Msg.To = “toEMail@SomeSite.com”
Msg.Subject = “Demo Message”
Smtp.Send(Msg)
End Sub
End Module
Posted in Network Remote | Leave a Comment »
Posted by nicesource on 2009/04/11
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("UserDomainName: " & System.Environment.UserDomainName)
End Sub
End Class
Posted in Network Remote | Leave a Comment »
Posted by nicesource on 2009/04/11
Imports System
Public Class MainClass
Shared Sub Main()
Dim doc As New Document("Test Document")
' only cast if it is safe
If TypeOf doc Is IStorable Then
Dim isDoc As IStorable = doc
isDoc.Read( )
Else
Console.WriteLine("Could not cast to IStorable")
End If
' this test will fail
If TypeOf doc Is ICompressible Then
Dim icDoc As ICompressible = doc
icDoc.Compress( )
Else
Console.WriteLine("Could not cast to ICompressible")
End If
End Sub
End Class
Interface IStorable
Sub Read( )
Sub Write(ByVal obj As Object)
Property Status( ) As Integer
End Interface
Interface ICompressible
Sub Compress( )
Sub Decompress( )
End Interface
Public Class Document
Implements IStorable
Public Sub New(ByVal s As String)
Console.WriteLine("Creating document with: {0}", s)
End Sub
Public Sub Read( ) Implements IStorable.Read
Console.WriteLine("Implementing the Read Method for IStorable")
End Sub
Public Sub Write(ByVal o As Object) Implements IStorable.Write
Console.WriteLine( _
"Implementing the Write Method for IStorable")
End Sub
Public Property Status( ) As Integer Implements IStorable.Status
Get
Return Status
End Get
Set(ByVal Value As Integer)
Status = Value
End Set
End Property
Private myStatus As Integer = 0
End Class
Posted in Language Basics | Leave a Comment »
Posted by nicesource on 2009/04/11
Imports System
Imports System.Data
Imports System.Collections
public class MainClass
Shared Sub Main()
Dim testvar As New A()
Console.WriteLine("Before IsFalse And IsFalse")
If testvar.IsFalse And testvar.IsFalse Then
End If
Console.WriteLine("Before IsFalse AndAlso IsFalse")
If testvar.IsFalse AndAlso testvar.IsFalse Then
End If
End Sub
End Class
Class A
Public ReadOnly Property IsTrue() As Boolean
Get
Console.WriteLine("IsTrue was called")
Return True
End Get
End Property
Public ReadOnly Property IsFalse() As Boolean
Get
Console.WriteLine("IsFalse was called")
Return False
End Get
End Property
End Class
Posted in Language Basics | Leave a Comment »