<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net%2FClass%2FClass_Define</id>
		<title>VB.Net/Class/Class Define - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net%2FClass%2FClass_Define"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/Class/Class_Define&amp;action=history"/>
		<updated>2026-04-05T23:36:41Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net/Class/Class_Define&amp;diff=376&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/Class/Class_Define&amp;diff=376&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:06Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net/Class/Class_Define&amp;diff=377&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net/Class/Class_Define&amp;diff=377&amp;oldid=prev"/>
				<updated>2010-05-26T12:42:47Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Class Composition==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
Imports System&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    Shared Sub Main(ByVal args As String())&lt;br /&gt;
      Dim s As New CStudent( _&lt;br /&gt;
         &amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, 7, 24, 1949, 3, 12, 1988)&lt;br /&gt;
      Console.WriteLine(s.ToStandardString() )&lt;br /&gt;
      &lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&amp;quot; Encapsulates month, day and year.&lt;br /&gt;
Class CDay&lt;br /&gt;
   Inherits Object&lt;br /&gt;
   Private mMonth As Integer &amp;quot; 1-12&lt;br /&gt;
   Private mDay As Integer &amp;quot; 1-31 based on month&lt;br /&gt;
   Private mYear As Integer &amp;quot; any year&lt;br /&gt;
   Public Sub New(ByVal monthValue As Integer, _&lt;br /&gt;
      ByVal dayValue As Integer, ByVal yearValue As Integer)&lt;br /&gt;
      mMonth = monthValue&lt;br /&gt;
      mYear = yearValue&lt;br /&gt;
      mDay = dayValue&lt;br /&gt;
   End Sub &amp;quot; New&lt;br /&gt;
   &amp;quot; create string containing month/day/year format&lt;br /&gt;
   Public Function ToStandardString() As String&lt;br /&gt;
      Return mMonth &amp;amp; &amp;quot;/&amp;quot; &amp;amp; mDay &amp;amp; &amp;quot;/&amp;quot; &amp;amp; mYear&lt;br /&gt;
   End Function&lt;br /&gt;
End Class &lt;br /&gt;
&lt;br /&gt;
&amp;quot; Represent student name, birthday and hire date.&lt;br /&gt;
Class CStudent&lt;br /&gt;
   Inherits Object&lt;br /&gt;
   Private mFirstName As String&lt;br /&gt;
   Private mLastName As String&lt;br /&gt;
   Private mBirthDate As CDay &amp;quot; member object reference&lt;br /&gt;
   Private mHireDate As CDay &amp;quot; member object reference&lt;br /&gt;
   &amp;quot; CStudent constructor&lt;br /&gt;
   Public Sub New(ByVal firstNameValue As String, _&lt;br /&gt;
      ByVal lastNameValue As String, _&lt;br /&gt;
      ByVal birthMonthValue As Integer, _&lt;br /&gt;
      ByVal birthDayValue As Integer, _&lt;br /&gt;
      ByVal birthYearValue As Integer, _&lt;br /&gt;
      ByVal hireMonthValue As Integer, _&lt;br /&gt;
      ByVal hireDayValue As Integer, _&lt;br /&gt;
      ByVal hireYearValue As Integer)&lt;br /&gt;
      mFirstName = firstNameValue&lt;br /&gt;
      mLastName = lastNameValue&lt;br /&gt;
      &amp;quot; create CDay instance for employee birthday&lt;br /&gt;
      mBirthDate = New CDay(birthMonthValue, birthDayValue, _&lt;br /&gt;
         birthYearValue)&lt;br /&gt;
      &amp;quot; create CDay instance for employee hire date&lt;br /&gt;
      mHireDate = New CDay(hireMonthValue, hireDayValue, _&lt;br /&gt;
         hireYearValue)&lt;br /&gt;
   End Sub &amp;quot; New&lt;br /&gt;
   &amp;quot; return employee information as standard-format String&lt;br /&gt;
   Public Function ToStandardString() As String&lt;br /&gt;
      Return mLastName &amp;amp; &amp;quot;, &amp;quot; &amp;amp; mFirstName &amp;amp; &amp;quot; Hired: &amp;quot; _&lt;br /&gt;
         &amp;amp; mHireDate.ToStandardString() &amp;amp; &amp;quot; Birthday: &amp;quot; &amp;amp; _&lt;br /&gt;
         mBirthDate.ToStandardString()&lt;br /&gt;
   End Function &amp;quot; ToStandardString&lt;br /&gt;
End Class &amp;quot; CStudent&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Define and use your own Time Class==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
Imports System&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    Shared Sub Main(ByVal args As String())&lt;br /&gt;
      Dim time As New CTime() &amp;quot; call CTime constructor&lt;br /&gt;
      Console.WriteLine( &amp;quot;The initial universal times is: &amp;quot; &amp;amp; _&lt;br /&gt;
         time.ToUniversalString() &amp;amp; vbCrLf &amp;amp; _&lt;br /&gt;
         &amp;quot;The initial standard time is: &amp;quot; &amp;amp; _&lt;br /&gt;
         time.ToStandardString() )&lt;br /&gt;
      time.SetTime(13, 27, 6) &amp;quot; set time with valid settings&lt;br /&gt;
      Console.WriteLine( &amp;quot;Universal time after setTime is: &amp;quot; &amp;amp; _&lt;br /&gt;
         time.ToUniversalString() &amp;amp; vbCrLf &amp;amp; _&lt;br /&gt;
         &amp;quot;Standard time after setTime is: &amp;quot; &amp;amp; _&lt;br /&gt;
         time.ToStandardString() )&lt;br /&gt;
      time.SetTime(99, 99, 99) &amp;quot; set time with invalid settings&lt;br /&gt;
      Console.WriteLine( &amp;quot;After attempting invalid settings: &amp;quot; &amp;amp; vbCrLf &amp;amp; _&lt;br /&gt;
         &amp;quot;Universal time: &amp;quot; &amp;amp; time.ToUniversalString() &amp;amp; _&lt;br /&gt;
         vbCrLf &amp;amp; &amp;quot;Standard time: &amp;quot; &amp;amp; time.ToStandardString() )&lt;br /&gt;
&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
Class CTime&lt;br /&gt;
   Inherits Object&lt;br /&gt;
   Private mHour As Integer &amp;quot; 0 - 23&lt;br /&gt;
   Private mMinute As Integer &amp;quot; 0 - 59&lt;br /&gt;
   Private mSecond As Integer &amp;quot; 0 - 59&lt;br /&gt;
   Public Sub New()&lt;br /&gt;
      SetTime(0, 0, 0)&lt;br /&gt;
   End Sub &amp;quot; New&lt;br /&gt;
   Public Sub SetTime(ByVal hourValue As Integer, _&lt;br /&gt;
      ByVal minuteValue As Integer, ByVal secondValue As Integer)&lt;br /&gt;
      If (hourValue &amp;gt;= 0 AndAlso hourValue &amp;lt; 24) Then&lt;br /&gt;
         mHour = hourValue&lt;br /&gt;
      Else&lt;br /&gt;
         mHour = 0&lt;br /&gt;
      End If&lt;br /&gt;
      If (minuteValue &amp;gt;= 0 AndAlso minuteValue &amp;lt; 60) Then&lt;br /&gt;
         mMinute = minuteValue&lt;br /&gt;
      Else&lt;br /&gt;
         mMinute = 0&lt;br /&gt;
      End If&lt;br /&gt;
      If (secondValue &amp;gt;= 0 AndAlso secondValue &amp;lt; 60) Then&lt;br /&gt;
         mSecond = secondValue&lt;br /&gt;
      Else&lt;br /&gt;
         mSecond = 0&lt;br /&gt;
      End If&lt;br /&gt;
   End Sub &amp;quot; SetTime&lt;br /&gt;
   &amp;quot; convert String to universal-time format&lt;br /&gt;
   Public Function ToUniversalString() As String&lt;br /&gt;
      Return String.Format(&amp;quot;{0}:{1:D2}:{2:D2}&amp;quot;, _&lt;br /&gt;
         mHour, mMinute, mSecond)&lt;br /&gt;
   End Function &amp;quot; ToUniversalString&lt;br /&gt;
   &amp;quot; convert to String in standard-time format&lt;br /&gt;
   Public Function ToStandardString() As String&lt;br /&gt;
      Dim suffix As String = &amp;quot; PM&amp;quot;&lt;br /&gt;
      Dim format As String = &amp;quot;{0}:{1:D2}:{2:D2}&amp;quot;&lt;br /&gt;
      Dim standardHour As Integer&lt;br /&gt;
      &amp;quot; determine whether time is AM or PM&lt;br /&gt;
      If mHour &amp;lt; 12 Then&lt;br /&gt;
         suffix = &amp;quot; AM&amp;quot;&lt;br /&gt;
      End If&lt;br /&gt;
      &amp;quot; convert from universal-time format to standard-time format&lt;br /&gt;
      If (mHour = 12 OrElse mHour = 0) Then&lt;br /&gt;
         standardHour = 12&lt;br /&gt;
      Else&lt;br /&gt;
         standardHour = mHour Mod 12&lt;br /&gt;
      End If&lt;br /&gt;
      Return String.Format(format, standardHour, mMinute, _&lt;br /&gt;
         mSecond) &amp;amp; suffix&lt;br /&gt;
   End Function &amp;quot; ToStandardString&lt;br /&gt;
End Class &amp;quot; CTime&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Nested Class Demo==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
Imports System&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    &lt;br /&gt;
    Shared Sub Main()&lt;br /&gt;
         Dim f1 As New Fraction(3, 4)&lt;br /&gt;
         Console.WriteLine(&amp;quot;f1: {0}&amp;quot;, f1.ToString(  ))&lt;br /&gt;
         Dim fa As New Fraction.FractionArtist(  )&lt;br /&gt;
         fa.Draw(f1)&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
 Public Class Fraction&lt;br /&gt;
     Private numerator As Integer&lt;br /&gt;
     Private denominator As Integer&lt;br /&gt;
     Public Sub New( _&lt;br /&gt;
       ByVal numerator As Integer, ByVal denominator As Integer)&lt;br /&gt;
         Me.numerator = numerator&lt;br /&gt;
         Me.denominator = denominator&lt;br /&gt;
     End Sub &amp;quot;New&lt;br /&gt;
     Public Overrides Function ToString(  ) As String&lt;br /&gt;
         Return [String].Format(&amp;quot;{0}/{1}&amp;quot;, numerator, denominator)&lt;br /&gt;
     End Function &amp;quot;ToString&lt;br /&gt;
     &amp;quot; Nested Class&lt;br /&gt;
     Class FractionArtist&lt;br /&gt;
         Public Sub Draw(ByVal f As Fraction)&lt;br /&gt;
             Console.WriteLine(&amp;quot;Drawing the numerator: {0}&amp;quot;, f.numerator)&lt;br /&gt;
             Console.WriteLine( _&lt;br /&gt;
                 &amp;quot;Drawing the denominator: {0}&amp;quot;, f.denominator)&lt;br /&gt;
         End Sub &amp;quot;Draw&lt;br /&gt;
     End Class &amp;quot;FractionArtist&lt;br /&gt;
 End Class &amp;quot;Fraction&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Your Complex Number Class==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;&lt;br /&gt;
There is a minor bug though. The unary minus operator is incorrect.&lt;br /&gt;
    Public Shared Operator -(ByVal c1 As Complex) As Complex&lt;br /&gt;
        Return New Complex(c1.imaginaryPart, c1.realPart)&lt;br /&gt;
    End Operator&lt;br /&gt;
This should be replaced with&lt;br /&gt;
    Public Shared Operator -(ByVal c1 As Complex) As Complex&lt;br /&gt;
        Return New Complex(-c1.realPart, -c1.imaginaryPart)&lt;br /&gt;
    End Operator&lt;br /&gt;
and perhaps an additional function like&lt;br /&gt;
    Public function Conjungate() As Complex&lt;br /&gt;
        Return New Complex(realPart, -imaginaryPart)&lt;br /&gt;
    End Function&lt;br /&gt;
And you might consider adding a .Length function equal to the current narrowing.&lt;br /&gt;
(And mathematically preferable replacing it, since converting complex-&amp;gt;real isn&amp;quot;t well-defined)&lt;br /&gt;
Best regards&lt;br /&gt;
Eske Rahn&lt;br /&gt;
rahn at sol.dk       &lt;br /&gt;
       &lt;br /&gt;
       &lt;br /&gt;
Imports System&lt;br /&gt;
Public Class MainClass&lt;br /&gt;
    Shared Sub Main(ByVal args As String())&lt;br /&gt;
        Dim X, Y As Complex&lt;br /&gt;
        X = New Complex(1, 2)&lt;br /&gt;
        Y = New Complex(3, 4)&lt;br /&gt;
        Console.WriteLine( (X + Y).ToString )&lt;br /&gt;
        Console.WriteLine( (X - Y).ToString )&lt;br /&gt;
        Console.WriteLine( (X * Y).ToString )&lt;br /&gt;
        Console.WriteLine( (X = Y).ToString )&lt;br /&gt;
        Console.WriteLine( (X &amp;lt;&amp;gt; Y).ToString )&lt;br /&gt;
        Console.WriteLine( (-X).ToString )&lt;br /&gt;
        Dim abs_x As Double = CDbl(X)&lt;br /&gt;
        Console.WriteLine(  abs_x.ToString )&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
Public Class Complex&lt;br /&gt;
    Public realPart As Double&lt;br /&gt;
    Public imaginaryPart As Double&lt;br /&gt;
    &amp;quot; Constructors.&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
    End Sub&lt;br /&gt;
    Public Sub New(ByVal real_part As Double, ByVal imaginary_part As Double)&lt;br /&gt;
        realPart = real_part&lt;br /&gt;
        imaginaryPart = imaginary_part&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot; ToString.&lt;br /&gt;
    Public Overrides Function ToString() As String&lt;br /&gt;
        Return realPart.ToString &amp;amp; &amp;quot; + &amp;quot; &amp;amp; imaginaryPart.ToString &amp;amp; &amp;quot;i&amp;quot;&lt;br /&gt;
    End Function&lt;br /&gt;
    &amp;quot; Operators.&lt;br /&gt;
    Public Shared Operator *(ByVal c1 As Complex, ByVal c2 As Complex) As Complex&lt;br /&gt;
        Return New Complex( _&lt;br /&gt;
            c1.realPart * c2.realPart - c1.imaginaryPart * c2.imaginaryPart, _&lt;br /&gt;
            c1.realPart * c2.imaginaryPart + c1.imaginaryPart * c2.realPart)&lt;br /&gt;
    End Operator&lt;br /&gt;
    Public Shared Operator +(ByVal c1 As Complex, ByVal c2 As Complex) As Complex&lt;br /&gt;
        Return New Complex( _&lt;br /&gt;
            c1.realPart + c2.realPart, _&lt;br /&gt;
            c1.imaginaryPart + c2.imaginaryPart)&lt;br /&gt;
    End Operator&lt;br /&gt;
    Public Shared Operator -(ByVal c1 As Complex, ByVal c2 As Complex) As Complex&lt;br /&gt;
        Return New Complex( _&lt;br /&gt;
            c1.realPart - c2.realPart, _&lt;br /&gt;
            c1.imaginaryPart - c2.imaginaryPart)&lt;br /&gt;
    End Operator&lt;br /&gt;
    Public Shared Operator =(ByVal c1 As Complex, ByVal c2 As Complex) As Boolean&lt;br /&gt;
        Return (c1.realPart = c2.realPart) AndAlso (c1.imaginaryPart = c2.imaginaryPart)&lt;br /&gt;
    End Operator&lt;br /&gt;
    Public Shared Operator &amp;lt;&amp;gt;(ByVal c1 As Complex, ByVal c2 As Complex) As Boolean&lt;br /&gt;
        Return (c1.realPart &amp;lt;&amp;gt; c2.realPart) OrElse (c1.imaginaryPart &amp;lt;&amp;gt; c2.imaginaryPart)&lt;br /&gt;
    End Operator&lt;br /&gt;
    Public Shared Operator -(ByVal c1 As Complex) As Complex&lt;br /&gt;
        Return New Complex(c1.imaginaryPart, c1.realPart)&lt;br /&gt;
    End Operator&lt;br /&gt;
    Public Shared Narrowing Operator CType(ByVal c1 As Complex) As Double&lt;br /&gt;
        Return System.Math.Sqrt(c1.realPart * c1.realPart + c1.imaginaryPart * c1.imaginaryPart)&lt;br /&gt;
    End Operator&lt;br /&gt;
End Class&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>