29-03-14, 07:50 AM
دي فكرة أخري
كود :
Public Class Form1
Private first As Person
Private second As Person
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
first = New Person
second = New Person
Dim item1 As Double = 2
Dim item2 As Double = 4
Dim item3 As Double = 6
Me.ListBox1.Items.Add(first.Calculate(item1, item2))
first.Name = "Ahmed"
Me.ListBox1.Items.Add(first.Name)
Me.ListBox1.Items.Add(second.Calculate(item1, item2 + item3))
second.Name = "Ibrahim"
second.Number = "1000"
Me.ListBox1.Items.Add(second.Name)
Me.ListBox1.Items.Add(second.Number)
End Sub
End Class
Public Structure Person
Public Name As String
Public Number As String
Public Function Calculate(firstItem As Double, SecondItem As Double)
Return firstItem + SecondItem
End Function
Public Function Calculate(firstItem As Double, SecondItem As Double, thirdItem As Integer)
Return firstItem + SecondItem + thirdItem
End Function
End Structure
