nindex = nindex + 1
end if
loop
'以下为打乱人员顺序10次
dim i as integer
dim j as integer
dim temp as string
dim nrandomnum as integer
for j = 0 to 10
for i = 0 to nmaxindex - 1
nrandomnum = ((nmaxindex - 1) × rnd) '利用rnd函数
temp = m_strnamearray(i).strname
m_strnamearray(i).strname = m_strnamearray(nrandomnum).strname
m_strnamearray(nrandomnum).strname = temp
next i
next j
end sub
private sub init() '读取ini文件
dim x as long
dim lpfilename
dim temp as string × 50
lpfilename = app.path + “\sortition.ini"
x = getprivateprofilestring(“system",“apptitle",“抽奖程序", temp, len(temp), lpfilename)
m_strapptitle = trim(temp)
temp =“"
x = getprivateprofilestring(“system", "title", "欢迎使用抽奖程序", temp, len(temp), lpfilename)
m_strtitle = trim(temp)
temp = “"
x = getprivateprofilestring(“system",“scrolltitleright", “恭喜发财!!!", temp, len(temp), lpfilename)
m_strscrolltitleright = trim(temp)
x = getprivateprofilestring(“system",“scrolltitleleft", “龙年大发!!!", temp, len(temp), lpfilename)
m_strscrolltitleleft = trim(temp)
form_bouns.caption = m_strapptitle
label_companytitle.caption = m_strtitle
end sub
模块源程序:
'用于读取ini文件的api函数
declare function getprivateprofilestring lib “kernel32" alias “getprivateprofilestringa" (byval lpapplicationname as string, byval lpkeyname as string, byval lpdefault as string, byval lpreturnedstring as string, byval nsize as long, byval lpfilename as string) as long
public type myname
strname as string
bisselect as boolean
end type
由于程序利用的windows ini文件保存一些标题信息,因而可以方便的修改使用环境,及标题内容。
见ini文件内容:
[system]
;应用程序的form名称
apptitle=“风云电脑抽奖test"
;窗口的内的标题(限9个字)
title=“大抽奖"
;右滚动的文字(仅能为如下格式:xxxx!!!)
scrolltitleright=“恭喜发财!!!"
;左滚动的文字(仅能为如下格式:xxxx!!!)
scrolltitleleft=“祝您好运!!!"
如此一个小小的电脑抽奖程序便完成了。
以上程序在vb6.0 windows98环境下编译通过!(武汉 蒋锦霞)