1.mediator抽象及具體類
public mustinherit class mediator
public mustoverride sub send(byval message as string, byval colleague as colleague)
end class
public class concretemediaotr
inherits mediator
private _colleague1 as concretecolleague1
private _colleague2 as concretecolleague2
public property colleague1 as concretecolleague1
getreturn _colleague1
end get
set(byval value as concretecolleague1)
_colleague1 = value
end set
end property
public property colleague2 as concretecolleague2
getreturn _colleague2
end get
set(byval value as concretecolleague2)
_colleague2 = value
end set
end property
public overrides sub send(byval message as string, byval colleague as colleague)
if colleague is colleague1 then
colleague2.notify(message)
else
colleague1.notify(message)
end if
end sub
end class
2.同事抽象及具體灰
public mustinherit class colleague
protected mymediator as mediator
public sub new(byval mediator as mediator)
me.mymediator = mediator
end sub
end class
public class concretecolleague1
inherits colleague
public sub new(byval mediator as mediator)
mybase.new(mediator)
end sub
public sub send(byval message as string)
mymediator.send(message, me)
end sub
public sub notify(byval message as string)
console.writeline("同事1得到同事2發來的資訊:" & message)
end sub
end class
public class concretecolleague2
inherits colleague
public sub new(byval mediator as mediator)
mybase.new(mediator)
end sub
public sub send(byval message as string)
mymediator.send(message, me)
end sub
public sub notify(byval message as string)
console.writeline("同事2得到同事1發來的資訊:" & message)
end sub
end class
3.客戶端
module module1
sub main()
dim m as new concretemediaotr
dim c1 as new concretecolleague1(m)
dim c2 as new concretecolleague2(m)
m.colleague1 = c1
m.colleague2 = c2
c1.send("吃了嗎?")
c2.send("沒呢,你請客嗎?")
c1.send("沒吃還不趕緊回家去吃呀。")
c2.send("g-u-n")
console.writeline("---------------")
c1.send("吃了嗎?")
c2.send("吃過了")
c1.send("再吃點不?我請客。")
c2.send("有多遠滾多遠,有多快滾多快...")
console.read()
end sub
end module
Visual Basic中的Split函式
返回乙個從零開始的一維陣列,其中包含指定數量的子字串。function split byval expression as string,optional byval delimiter as string optional byval limit as integer 1,optional byv...
在Visual Basic 6 0中操縱XML檔案
擴充套件標記語言 xml是一種簡單的資料儲存語言,使用一系列簡單的標記描述資料,而這些標記可以用方便的方式建立,雖然 xml占用的空間比二進位制資料要占用更多的空間,但 xml極其簡單易於掌握和使用。xml與access,oracle和sql server等資料庫不同,資料庫提供了更強有力的資料儲存...
在Visual Basic程式設計中運用資料結構
在visual basic程式設計中運用資料結構 章新蘇 江蘇省水利科學研究所材料結構室 摘要 本文討論了在vb程式設計中利用陣列和自定義資料型別構造鍊錶 棧和佇列等資料結構的方法。1 引言basic 語言擁有較高的普及率,同時在 windows 作業系統中 visual basic 以功能強 量小...