问个挺着急的问题

狐狸大仙 2004-09-17 04:26:41
Class A
function aaaa()
if xxxx() then
return
else
...............
end if
end function
End Class
clsss B
function xxxx() as boolean
end function
End Class

问题就是,现在有A,A中我想做一个方法,根据该方法的返回值进行后面的操作。
而具体的方法的内容,我想在B中实现。我该怎么写啊?请给出具体点的说明。
...全文
142 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
狐狸大仙 2004-09-18
  • 打赏
  • 举报
回复
问题已经大约解决了。
当然还是有些小问题。
实际的问题是这样的。
有一个页面A基类继承于Page,有一个控件B继承于DataGrid。页面C是实际页面继承于A。
B中要实现一个方法用于做数据检查。但是这个检查方法的代码要由C去实现,并且传回一个返回值。

最后的做法是:
转换B中的Page实例为A类,执行A类的检查方法。C重写该检查方法。

谢谢大家的建议。

ny_nicholas 2004-09-18
  • 打赏
  • 举报
回复
同意樓上的
NULLvalue 2004-09-18
  • 打赏
  • 举报
回复
方法能被调用至少得是public,如果不想实例化就用那得用shared定义为共享
exing 2004-09-18
  • 打赏
  • 举报
回复
Class A
function aaaa()
if b.xxxx() then
return
else
...............
end if
end function
End Class
clsss B
Public shared function xxxx() as boolean
.............
end function
End Class
ny_nicholas 2004-09-17
  • 打赏
  • 举报
回复
up
kellymax 2004-09-17
  • 打赏
  • 举报
回复
有没有那么烦?既然是类的话为什么可以用对象?

class A

public function aaaa()

end class

class B

'定义a是A类的
dim a as A
dim b as object
'调用A类里的aaaa()返回什么你自己看着办不就成了吗?
b = a.aaaa()

end class

这样做不是简单易懂么?我也是菜鸟一只,说错了别骂请指教
bruse82 2004-09-17
  • 打赏
  • 举报
回复
Class A
function aaaa()
if xxxx() then
return x
else
return y
end if
end function

function bbbb()
if me.aaaa()= x then
DoSomething1()
else
DoSomething2()
end if
end function

Protect Overridable sub DoSomething1()
end function

Protect Overridable sub DoSomething2()
end function
End Class

clsss B
inherit A
Protect Overridable sub DoSomething1()
方法实现
end function

Protect Overridable sub DoSomething2()
方法实现
end function
End Class

狐狸大仙 2004-09-17
  • 打赏
  • 举报
回复
还有一些要说明的。
A 和 B 不能互相继承
A 的存在并不要求B也存在。只要C能完成也行。
smoothwood 2004-09-17
  • 打赏
  • 举报
回复
把B中这个函数设为共享函数,具体如下:
B中:
---------
Public Class B
Public Shared Function xxxx() As Integer
Return 1
End Function
End Class
----------
A中:
Public Class A
Function aaaa()
If B.xxxx > 1 Then
MessageBox.Show(">1")
Else
MessageBox.Show("<=1")
End If
End Function
End Class
-------------
调用:
Dim obja As New A
obja.aaaa()
Ernestvivi 2004-09-17
  • 打赏
  • 举报
回复
Class A
function aaaa() as string
if xxxx() then
dim r as string
r=""
return r
else
...............
end if
end function
End Class
clsss B
inherit A
if r= then
function xxxx() as boolean
end function


End Class

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧