VB.Net中文教程(3)程序多重定义(5)
Inherits Person
Private student_number As Integer
Public Overloads Sub SetValue( ByVal na As String, ByVal a As Integer, ByVal
no As Integer)
SetValue(na, a)
student_number = no
End Sub
Public Overrides Sub Display()
MyBase.Display()
Messagebox.Show("StudNo: " + str(student_number))
End Sub
End Class
-----------------------------------------------------------------------------------------
Public Class Form1
Inherits System.WinForms.Form
Public Sub New()
MyBase.New()
Form1 = Me
This call is required by the Win Form Designer.
InitializeComponent()
TODO: Add any initialization after the InitializeComponent() call
End Sub
Form overrides dispose to clean up the component list.
Public Overrides Sub Dispose()
MyBase.Dispose()
components.Dispose()
End Sub
#Region " Windows Form Designer generated code "
........
#End Region
Protected Sub Form1_Click( ByVal sender As Object, ByVal
e As System.EventArgs)
Dim x As New Person()
x.SetValue("Alvin", 32)
Dim y As New Student()
y.SetValue("Tom", 36, 11138)
x.Display()
y.Display()
End Sub
End Class
此程序输出﹕
Name: Alvin Age: 32
Name: Tom Age: 36
StudNo: 11138
此时﹐Student 类别含有两个SetValue()程序,一个是从Person类别继承而来,另一个是自行定义的。如果上述Form1_Click()内的指令更改如下:
Dim y As New Student()
y.SetValue("Tom", 36, 5000.25) Error!
y.Display()
补充:软件开发 , Vb ,
- 更多VB疑问解答:
- vb把图片转换成 base64代码
- 批处理转移文 之errorlevel
- vb 6.0 调用vb.net dll混合程序集错误
- VB inet控件访问ftp 本机测试通过客户机inet控件使用失败。急!!
- 求助在Dir1控件当前目录下新建一个文件夹的代码
- CreateObject创建Word Excel对象失败,提示,无法加载DLL,怎么解决?
- 有两个磁盘阵列,如何使用能达到最好的效果
- cloudStack 如何实现 vSphere的DRS功能
- 和难缠客户的那些事儿
- 批处理转移文 之errorlevel
- vb 6.0 调用vb.net dll混合程序集错误
- VB inet控件访问ftp 本机测试通过客户机inet控件使用失败。急!!
- 求助在Dir1控件当前目录下新建一个文件夹的代码
- CreateObject创建Word Excel对象失败,提示,无法加载DLL,怎么解决?
- 有两个磁盘阵列,如何使用能达到最好的效果