الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[ مشكلة لدي في ال Inherits .. فمن يعينني .. ]

مغلق
بدأه Dr.Cisco في 8 يناير 2007 · 4 رد · 814 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ..

مساء الخير .. أحبتي الفضلاء ..

لدي مشكلة في مخرجات البرنامج ..

فلا تظهر المطلوب ..

أعتقد أن في الـ Inherits مشكلة ..

فمن يعينني على الحل أحبتي ..

 

Public Class Form1
	Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

	Public Sub New()
		MyBase.New()

		'This call is required by the Windows Form Designer.
		InitializeComponent()

		'Add any initialization after the InitializeComponent() call

	End Sub

	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
		If disposing Then
			If Not (components Is Nothing) Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(disposing)
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
	Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
	Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
	Friend WithEvents Label1 As System.Windows.Forms.Label
	Friend WithEvents Label2 As System.Windows.Forms.Label
	Friend WithEvents Label3 As System.Windows.Forms.Label
	Friend WithEvents Label4 As System.Windows.Forms.Label
	Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker
	Friend WithEvents Button1 As System.Windows.Forms.Button
	Friend WithEvents Button2 As System.Windows.Forms.Button
	Friend WithEvents Button3 As System.Windows.Forms.Button
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.TextBox1 = New System.Windows.Forms.TextBox
		Me.TextBox2 = New System.Windows.Forms.TextBox
		Me.TextBox3 = New System.Windows.Forms.TextBox
		Me.Label1 = New System.Windows.Forms.Label
		Me.Label2 = New System.Windows.Forms.Label
		Me.Label3 = New System.Windows.Forms.Label
		Me.Label4 = New System.Windows.Forms.Label
		Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker
		Me.Button1 = New System.Windows.Forms.Button
		Me.Button2 = New System.Windows.Forms.Button
		Me.Button3 = New System.Windows.Forms.Button
		Me.SuspendLayout()
		'
		'TextBox1
		'
		Me.TextBox1.Location = New System.Drawing.Point(80, 16)
		Me.TextBox1.Name = "TextBox1"
		Me.TextBox1.Size = New System.Drawing.Size(200, 23)
		Me.TextBox1.TabIndex = 0
		Me.TextBox1.Text = ""
		'
		'TextBox2
		'
		Me.TextBox2.Location = New System.Drawing.Point(344, 16)
		Me.TextBox2.Name = "TextBox2"
		Me.TextBox2.Size = New System.Drawing.Size(104, 23)
		Me.TextBox2.TabIndex = 1
		Me.TextBox2.Text = ""
		'
		'TextBox3
		'
		Me.TextBox3.Location = New System.Drawing.Point(344, 56)
		Me.TextBox3.Name = "TextBox3"
		Me.TextBox3.Size = New System.Drawing.Size(104, 23)
		Me.TextBox3.TabIndex = 2
		Me.TextBox3.Text = ""
		'
		'Label1
		'
		Me.Label1.Location = New System.Drawing.Point(8, 16)
		Me.Label1.Name = "Label1"
		Me.Label1.Size = New System.Drawing.Size(48, 16)
		Me.Label1.TabIndex = 3
		Me.Label1.Text = "Name :"
		'
		'Label2
		'
		Me.Label2.Location = New System.Drawing.Point(8, 56)
		Me.Label2.Name = "Label2"
		Me.Label2.Size = New System.Drawing.Size(80, 16)
		Me.Label2.TabIndex = 4
		Me.Label2.Text = "Brith of Date : "
		'
		'Label3
		'
		Me.Label3.Location = New System.Drawing.Point(288, 16)
		Me.Label3.Name = "Label3"
		Me.Label3.Size = New System.Drawing.Size(48, 16)
		Me.Label3.TabIndex = 5
		Me.Label3.Text = "Credits : "
		'
		'Label4
		'
		Me.Label4.Location = New System.Drawing.Point(288, 56)
		Me.Label4.Name = "Label4"
		Me.Label4.Size = New System.Drawing.Size(56, 16)
		Me.Label4.TabIndex = 6
		Me.Label4.Text = "Address :"
		'
		'DateTimePicker1
		'
		Me.DateTimePicker1.Location = New System.Drawing.Point(80, 56)
		Me.DateTimePicker1.Name = "DateTimePicker1"
		Me.DateTimePicker1.TabIndex = 7
		'
		'Button1
		'
		Me.Button1.Location = New System.Drawing.Point(8, 104)
		Me.Button1.Name = "Button1"
		Me.Button1.Size = New System.Drawing.Size(224, 40)
		Me.Button1.TabIndex = 8
		Me.Button1.Text = "Gradute"
		'
		'Button2
		'
		Me.Button2.Location = New System.Drawing.Point(240, 104)
		Me.Button2.Name = "Button2"
		Me.Button2.Size = New System.Drawing.Size(224, 40)
		Me.Button2.TabIndex = 9
		Me.Button2.Text = "UnGradute"
		'
		'Button3
		'
		Me.Button3.Location = New System.Drawing.Point(8, 152)
		Me.Button3.Name = "Button3"
		Me.Button3.Size = New System.Drawing.Size(456, 40)
		Me.Button3.TabIndex = 10
		Me.Button3.Text = "Close"
		'
		'Form1
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 16)
		Me.ClientSize = New System.Drawing.Size(472, 198)
		Me.Controls.Add(Me.Button3)
		Me.Controls.Add(Me.Button2)
		Me.Controls.Add(Me.Button1)
		Me.Controls.Add(Me.DateTimePicker1)
		Me.Controls.Add(Me.Label4)
		Me.Controls.Add(Me.Label3)
		Me.Controls.Add(Me.Label2)
		Me.Controls.Add(Me.Label1)
		Me.Controls.Add(Me.TextBox3)
		Me.Controls.Add(Me.TextBox2)
		Me.Controls.Add(Me.TextBox1)
		Me.Name = "Form1"
		Me.Text = "Form1"
		Me.ResumeLayout(False)

	End Sub

#End Region

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

	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim g As gradute
		g = New gradute(TextBox1.Text, DateTimePicker1.Value, TextBox3.Text, Convert.ToInt32(TextBox2.Text))
		MessageBox.Show(g.tellaboutself)

	End Sub

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		Close()
	End Sub

	Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged

	End Sub

	Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Dim u As ungradute
		u = New ungradute(TextBox1.Text, DateTimePicker1.Value, TextBox3.Text, Convert.ToInt32(TextBox2.Text))
		MessageBox.Show(u.tellaboutself)
	End Sub
End Class

Public MustInherit Class student

	Private namee As String
	Private Datee As Date
	Private address As String
	Private credits As Integer
	Public Sub New(ByVal nn As String, ByVal dd As Date, ByVal aa As String, ByVal cc As Integer)
		setname(nn)
		setdate(dd)
		setaddress(aa)
		setcreadits(cc)
	End Sub
	Public Sub setname(ByVal n As String)
		namee = n

	End Sub
	Public Sub setdate(ByVal d As Date)
		Datee = d

	End Sub
	Public Sub setaddress(ByVal a As String)
		address = a
	End Sub
	Public Sub setcreadits(ByVal c As Integer)

		Dim ex1 As Exception
		ex1 = New Exception("NO Vailed")


		If (c < 10) Then
			Throw ex1
		Else
			credits = c

		End If
	End Sub
	Public Function getname() As String
		Return namee
	End Function
	Public Function getdate() As Date
		Return Datee
	End Function
	Public Function getaddress() As String
		Return address
	End Function
	Public Function getcredits() As Integer
		Return credits
	End Function
	Public Overridable Function tellaboutself() As String
		Dim info As String
		Return info = " Name : " & namee & " Date of Bridth : " & Convert.ToString(Datee) & " Address : " & address & " Credite : " & Convert.ToString(credits)
	End Function

	Public MustOverride Function calcluteinvoce() As Integer
End Class

Public Class gradute
	Inherits student

	Private amount As Integer = 200
	Private a As String
	Public Sub New(ByVal n1 As String, ByVal d1 As Date, ByVal a1 As String, ByVal c1 As Integer)
		MyBase.New(n1, d1, a1, c1)
		seta(Convert.ToString(calcluteinvoce()))
	End Sub

	Public Sub seta(ByVal aa As String)
		a = aa
	End Sub

	Public Function geta() As String
		Return a
	End Function

	Public Overrides Function calcluteinvoce() As Integer
		Dim i As Integer
		i = amount + 0.5 * MyBase.getcredits() * amount
		Return i
	End Function


	Public Overrides Function tellaboutself() As String
		Return MyBase.tellaboutself() & "  The Amount is " & a
	End Function



End Class

Public Class ungradute
	Inherits student
	Private amount As Integer = 250
	Private b As String
	Public Sub New(ByVal n2 As String, ByVal d2 As Date, ByVal a2 As String, ByVal c2 As Integer)
		MyBase.New(n2, d2, a2, c2)
		setb(Convert.ToString(calcluteinvoce()))
	End Sub

	Public Sub setb(ByVal bb As String)
		b = bb
	End Sub

	Public Function getb() As String
		Return b
	End Function

	Public Overrides Function calcluteinvoce() As Integer

		Dim i As Integer
		i = amount + 0.7 * MyBase.getcredits() * amount
		Return i

	End Function

	Public Overrides Function tellaboutself() As String
		Return MyBase.tellaboutself() & "  The Amount is " & b
	End Function

End Class

تم تعديل هذه المشاركة بواسطة Dr.Cisco في 8 يناير 2007 في 01:05

#2

عزيزي ما هو المطلوب بالضبط , وما هي المشكلة لديك؟

يعني بمعنى اخر , مالذي تريد ان تعمله ولم تستطيع, لسبب مشكلةٍ ما .

في المثال يتضح المقال

#4

الأخوة جميعاً أعتدر عن تأخر الرد .. وأشكركم على التجاوب ..

البرنامج يقوم بإستقبال اسم ورقم الكريدت وتأريخ الميلاد والعنوان ..

عند الضغط على الباتن Gradut يقوم بعرض الرسالة والناتج المناسب ..

والتي تحتوي على الاسم ورقم الكريدت وتأريخ الميلاد والعنوان بالإضافة إلى الأماونت المخصص له ..

وكدلك عند الضغط على UnGradut يقوم بعرض الرسالة والناتج المناسب ..

والتي تحتوي على الاسم ورقم الكريدت وتأريخ الميلاد والعنوان بالإضافة إلى الأماونت المخصص له ..

طبعاً الأماونت تختلف بإختلاف الكلاسين ( خريج - غير خريج ) ..

المشكلة إنه عند العرض يخرج لي قيمة الأماونت لكن الباقي False ..

أفتونا يا أحبائنا ..

dr.cisco ..

#5

أبشركم ..

وجدت الحل المشكلة كانت في TellAboutSelf التابعة للـ Super Class ..

لتكون ..

Public Overridable Function tellaboutself() As String

		Return " Name : " & namee & " Date of Bridth : " & Convert.ToString(Datee) & " Address : " & address & " Credite : " & Convert.ToString(credits)
	End Function

شكراً لكم أحبتي جميعاً على الحرص والتعاون ..

dr.cisco ..

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…