'创建XML文档,常见完成后必须注销
'set aa=new myxml
'aa.xmlcreate()
wind= inputbox("操作类型:"&Chr(13)&"1=添加"&Chr(13)&"2=计算","EVE生产计算工具")
if wind=1 then
while wind<>""
wind= inputbox("添加操作:"&Chr(13)&"添加格式:名称、XML路径、成本、买价、卖价、生产时间、生产时间、数量、材料列表(用,分割数量)","EVE生产计算工具添加")
set aa=new matter
aa.matteradd wind
set aa=nothing
wend
else
wind= inputbox("生产计算:"&Chr(13)&"请输入物品名称"&Chr(13)&"不输入为全部计算!")
end if
class matter
public mattername,matterbuy,mattersell,matterxml'名称,卖价,买价,物价查询地址
publicreturnsell,returnbuy,producetime,cost'卖单日利润,买单日利润,生产时间(秒),成本(卖价成本)
public matterlist ,listobj() ,mattercostbuy,mattercostsell '材料列表,材料对象,采购价,收购价
'matterxml = http://www.ceve-market.org/api/market/type/34.xml
Private Sub Class_Initialize()'类创建初始化,无参数
end sub
public function mattercreate(strmattername)'真正的初始化物品名称
mattername=strmattername
set a=new myxml
'取得初始值
a.matterbuy=a.xmlget(mattername,"matterbuy")
a.mattersell=a.xmlget(mattername,"mattersell")
a.producetime=a.xmlget(mattername,"producetime")
a.matterlist1=a.xmlget(mattername,"matterlist")
a.matterxml=a.xmlget(mattername,matterxml)'拼接价格访问字符串
a.matterxml="http://www.ceve-market.org/api/market/region/10000002/type/"&matterxml&".xml"
a.setxmlpath(a.matterxml)
buy=a.xmlget("buy","max")
sell=a.xmlget("sell","min")
if buy>0then
a.matterbuy=buy
a.xmlrevise mattername,"matterbuy",matterbuy'更新价格
end if
if sell>0then
a.mattersell=sell
a.xmlrevise mattername,"mattersell",mattersell
end if
'递归材料核算成本
a.cost=0
matterlist =split(matterlist1,",")'得到材料列表
a.listnu=ubond(matterlist)
dim k
for i=0 to listnu step 2'创建材料列表对象
set k =new matter
k.mattername=a.matterlist(i)
k.mattercreate(k.mattername)
a.cost=cost+k.matterbuy*matterlist(i+1)'核算成本
j=j+1
next
'日利润核算
a.returnsell=(mattersell-a.cost)*3600*24/producetime
a.returnbuy=(matterbuy-a.cost)*3600*24/producetime
if a.returnbuy>30000000 then'日利润大于3000万
end if
if a.returnbuy < 10000000 then '日利润小于1000万
end if
end function
public function matteradd(mattername,matterxml,matterprice,matterbuy,mattersell,producetime,produceno,matterlist)'添加物品资料
'名称、XML路径、成本、买价,卖价,生产时间,数量,材料列表(用,分割)
set a=new myxml
a.xmladd mattername,matterxml,cost,matterbuy,mattersell,producetime,produceno,matterlist
end function
Private Sub class_terminate()'这里是类注销的时候自动执行的代码,无参数
end Sub
end class
class myxml
public xmlpath,xmlrootname,xmlDoc, rootE1,p
Private Sub Class_Initialize()'类创建初始化,无参数
xmlpath="d:\matter.xml"
xmlrootname="matterdata"
end sub
Private Sub class_terminate()'这里是类注销的时候自动执行的代码,无参数
set xmldoc =nothing
end Sub
public function setxmlpath(strpath)
xmlpath=strpath
end function
public function xmlcreate()
xmlpath="d:\matter.xml"
Set xmlDoc = CreateObject("MicroSoft.XMLDom") '创建XML对象,覆盖前XML文档
'创建根元素并将之加入文档
Set rootE1=xmlDoc.createElement(xmlrootname)'根节点
xmlDoc.appendChild rootE1
'rootE1.appendChild bookchild1
'创建 XML processing instruction,并把它加到根元素之前
Set p=xmlDoc.createProcessingInstruction("xml","version='1.0'")
xmlDoc.insertBefore p,xmlDoc.childNodes(0)
xmlDoc.Save xmlpath'把文件保存到D目录
set p =nothing
set rootE1 =nothing
set xmlDoc =nothing
end function
public function xmladd(mattername,matterxml,cost,matterbuy,mattersell,producetime,produceno,matterlist)
'名称、路径、成本、买价,卖价,生产时间,数量,材料列表(用,分割)
Set xmlDoc = CreateObject("MicroSoft.XMLDom") '创建XML对象
xmlDoc.Load(xmlpath)
Set rootE1=xmlDoc.createElement(xmlrootname)'根节点
set rootE1=xmlDoc.documentElement.SelectSingleNode("//"&xmlrootname)'查找节点
Set bookchild1=xmlDoc.createElement(mattername)'创建物品节点
Set ISDNAttribute=xmlDoc.createAttribute("mattername")'物品节点属性
ISDNAttribute.text=mattername'物品节点属性赋值
bookchild1.setAttributeNode ISDNAttribute'添加新属性
rootE1.appendChild bookchild1'物添加属性
'创建子节点
Set bookchild2=xmlDoc.createElement("matterxml")
bookchild2.text=matterxml
bookchild1.appendChild bookchild2
Set bookchild2=xmlDoc.createElement("cost")'成本节点
bookchild2.text=cost'价格节点属性赋值
bookchild1.appendChild bookchild2'添加子节点到节点
Set bookchild2=xmlDoc.createElement("matterbuy")'买价节点
bookchild2.text=matterbuy'价格节点属性赋值
bookchild1.appendChild bookchild2'添加子节点到节点
Set bookchild2=xmlDoc.createElement("mattersell")'卖价节点
bookchild2.text=mattersell'价格节点属性赋值
bookchild1.appendChild bookchild2'添加子节点到节点
Set bookchild2=xmlDoc.createElement("producetime")
bookchild2.text=producetime
bookchild1.appendChild bookchild2
Set bookchild2=xmlDoc.createElement("produceno")
bookchild2.text=produceno
bookchild1.appendChild bookchild2
Set bookchild2=xmlDoc.createElement("matterlist")
bookchild2.text=matterlist
bookchild1.appendChild bookchild2
rootE1.appendChild bookchild1
xmlDoc.Save xmlpath'把文件保存到D目录
set xmlDoc = nothing
end function
public function xmlrevise(mattername,matterdataname,matterdatavalue)'修改
Set xmlDoc = CreateObject("MicroSoft.XMLDom") '创建XML对象
xmlDoc.Load(xmlpath)
set z=xmlDoc.getElementsByTagName(mattername)(0)'取得物品节点
set y=z.getElementsByTagName(matterdataname)(0)
y.Text=matterdatavalue'修改节点值
xmlDoc.Save xmlpath'把文件保存到D目录
set xmlDoc = nothing
end function
public function xmlget(mattername,matterdataname)'节点值
Set xmlDoc = CreateObject("MicroSoft.XMLDom") '创建XML对象
xmlDoc.Load(xmlpath)
set z=xmlDoc.getElementsByTagName(mattername)(0)'取得物品节点
set y=z.getElementsByTagName(matterdataname)(0)
xmlget=y.text
end function
end class
'set aa=new myxml
'aa.xmlcreate()
wind= inputbox("操作类型:"&Chr(13)&"1=添加"&Chr(13)&"2=计算","EVE生产计算工具")
if wind=1 then
while wind<>""
wind= inputbox("添加操作:"&Chr(13)&"添加格式:名称、XML路径、成本、买价、卖价、生产时间、生产时间、数量、材料列表(用,分割数量)","EVE生产计算工具添加")
set aa=new matter
aa.matteradd wind
set aa=nothing
wend
else
wind= inputbox("生产计算:"&Chr(13)&"请输入物品名称"&Chr(13)&"不输入为全部计算!")
end if
class matter
public mattername,matterbuy,mattersell,matterxml'名称,卖价,买价,物价查询地址
publicreturnsell,returnbuy,producetime,cost'卖单日利润,买单日利润,生产时间(秒),成本(卖价成本)
public matterlist ,listobj() ,mattercostbuy,mattercostsell '材料列表,材料对象,采购价,收购价
'matterxml = http://www.ceve-market.org/api/market/type/34.xml
Private Sub Class_Initialize()'类创建初始化,无参数
end sub
public function mattercreate(strmattername)'真正的初始化物品名称
mattername=strmattername
set a=new myxml
'取得初始值
a.matterbuy=a.xmlget(mattername,"matterbuy")
a.mattersell=a.xmlget(mattername,"mattersell")
a.producetime=a.xmlget(mattername,"producetime")
a.matterlist1=a.xmlget(mattername,"matterlist")
a.matterxml=a.xmlget(mattername,matterxml)'拼接价格访问字符串
a.matterxml="http://www.ceve-market.org/api/market/region/10000002/type/"&matterxml&".xml"
a.setxmlpath(a.matterxml)
buy=a.xmlget("buy","max")
sell=a.xmlget("sell","min")
if buy>0then
a.matterbuy=buy
a.xmlrevise mattername,"matterbuy",matterbuy'更新价格
end if
if sell>0then
a.mattersell=sell
a.xmlrevise mattername,"mattersell",mattersell
end if
'递归材料核算成本
a.cost=0
matterlist =split(matterlist1,",")'得到材料列表
a.listnu=ubond(matterlist)
dim k
for i=0 to listnu step 2'创建材料列表对象
set k =new matter
k.mattername=a.matterlist(i)
k.mattercreate(k.mattername)
a.cost=cost+k.matterbuy*matterlist(i+1)'核算成本
j=j+1
next
'日利润核算
a.returnsell=(mattersell-a.cost)*3600*24/producetime
a.returnbuy=(matterbuy-a.cost)*3600*24/producetime
if a.returnbuy>30000000 then'日利润大于3000万
end if
if a.returnbuy < 10000000 then '日利润小于1000万
end if
end function
public function matteradd(mattername,matterxml,matterprice,matterbuy,mattersell,producetime,produceno,matterlist)'添加物品资料
'名称、XML路径、成本、买价,卖价,生产时间,数量,材料列表(用,分割)
set a=new myxml
a.xmladd mattername,matterxml,cost,matterbuy,mattersell,producetime,produceno,matterlist
end function
Private Sub class_terminate()'这里是类注销的时候自动执行的代码,无参数
end Sub
end class
class myxml
public xmlpath,xmlrootname,xmlDoc, rootE1,p
Private Sub Class_Initialize()'类创建初始化,无参数
xmlpath="d:\matter.xml"
xmlrootname="matterdata"
end sub
Private Sub class_terminate()'这里是类注销的时候自动执行的代码,无参数
set xmldoc =nothing
end Sub
public function setxmlpath(strpath)
xmlpath=strpath
end function
public function xmlcreate()
xmlpath="d:\matter.xml"
Set xmlDoc = CreateObject("MicroSoft.XMLDom") '创建XML对象,覆盖前XML文档
'创建根元素并将之加入文档
Set rootE1=xmlDoc.createElement(xmlrootname)'根节点
xmlDoc.appendChild rootE1
'rootE1.appendChild bookchild1
'创建 XML processing instruction,并把它加到根元素之前
Set p=xmlDoc.createProcessingInstruction("xml","version='1.0'")
xmlDoc.insertBefore p,xmlDoc.childNodes(0)
xmlDoc.Save xmlpath'把文件保存到D目录
set p =nothing
set rootE1 =nothing
set xmlDoc =nothing
end function
public function xmladd(mattername,matterxml,cost,matterbuy,mattersell,producetime,produceno,matterlist)
'名称、路径、成本、买价,卖价,生产时间,数量,材料列表(用,分割)
Set xmlDoc = CreateObject("MicroSoft.XMLDom") '创建XML对象
xmlDoc.Load(xmlpath)
Set rootE1=xmlDoc.createElement(xmlrootname)'根节点
set rootE1=xmlDoc.documentElement.SelectSingleNode("//"&xmlrootname)'查找节点
Set bookchild1=xmlDoc.createElement(mattername)'创建物品节点
Set ISDNAttribute=xmlDoc.createAttribute("mattername")'物品节点属性
ISDNAttribute.text=mattername'物品节点属性赋值
bookchild1.setAttributeNode ISDNAttribute'添加新属性
rootE1.appendChild bookchild1'物添加属性
'创建子节点
Set bookchild2=xmlDoc.createElement("matterxml")
bookchild2.text=matterxml
bookchild1.appendChild bookchild2
Set bookchild2=xmlDoc.createElement("cost")'成本节点
bookchild2.text=cost'价格节点属性赋值
bookchild1.appendChild bookchild2'添加子节点到节点
Set bookchild2=xmlDoc.createElement("matterbuy")'买价节点
bookchild2.text=matterbuy'价格节点属性赋值
bookchild1.appendChild bookchild2'添加子节点到节点
Set bookchild2=xmlDoc.createElement("mattersell")'卖价节点
bookchild2.text=mattersell'价格节点属性赋值
bookchild1.appendChild bookchild2'添加子节点到节点
Set bookchild2=xmlDoc.createElement("producetime")
bookchild2.text=producetime
bookchild1.appendChild bookchild2
Set bookchild2=xmlDoc.createElement("produceno")
bookchild2.text=produceno
bookchild1.appendChild bookchild2
Set bookchild2=xmlDoc.createElement("matterlist")
bookchild2.text=matterlist
bookchild1.appendChild bookchild2
rootE1.appendChild bookchild1
xmlDoc.Save xmlpath'把文件保存到D目录
set xmlDoc = nothing
end function
public function xmlrevise(mattername,matterdataname,matterdatavalue)'修改
Set xmlDoc = CreateObject("MicroSoft.XMLDom") '创建XML对象
xmlDoc.Load(xmlpath)
set z=xmlDoc.getElementsByTagName(mattername)(0)'取得物品节点
set y=z.getElementsByTagName(matterdataname)(0)
y.Text=matterdatavalue'修改节点值
xmlDoc.Save xmlpath'把文件保存到D目录
set xmlDoc = nothing
end function
public function xmlget(mattername,matterdataname)'节点值
Set xmlDoc = CreateObject("MicroSoft.XMLDom") '创建XML对象
xmlDoc.Load(xmlpath)
set z=xmlDoc.getElementsByTagName(mattername)(0)'取得物品节点
set y=z.getElementsByTagName(matterdataname)(0)
xmlget=y.text
end function
end class