抽奖程序(用vb编写)

发布时间:2025-12-09 15:32:24 浏览次数:10

在窗体上添加一个command1,一个timer1,label1(0~5)

控件数组(添加一个label1,然后再复制5个,共6个,用来显示数字),代码如下:

Private

Sub

Command1_Click()

If

Command1.Caption

=

"抽奖"

Then

Command1.Caption

=

"停止"

Timer1.Enabled

=

True

Else

Timer1.Enabled

=

False

Command1.Caption

=

"抽奖"

End

If

End

Sub

Private

Sub

Form_Load()

Command1.Caption

=

"抽奖"

Timer1.Interval

=

50

Timer1.Enabled

=

False

End

Sub

Private

Sub

Timer1_Timer()

Randomize

For

i

=

0

To

5

Label1(i)

=

Int(10

*

Rnd)

Select

Case

Label1(i).Caption

Case

0

Label1(i).BackColor

=

RGB(0,

0,

0)

Label1(i).ForeColor

=

RGB(255,

255,

255)

Case

1

Label1(i).BackColor

=

RGB(128,

42,

42)

Label1(i).ForeColor

=

RGB(127,

213,

213)

Case

2

Label1(i).BackColor

=

RGB(255,

0,

0)

Label1(i).ForeColor

=

RGB(0,

255,

255)

Case

3

Label1(i).BackColor

=

RGB(255,

97,

0)

Label1(i).ForeColor

=

RGB(0,

158,

255)

Case

4

Label1(i).BackColor

=

RGB(255,

255,

0)

Label1(i).ForeColor

=

RGB(0,

0,

255)

Case

5

Label1(i).BackColor

=

RGB(0,

255,

0)

Label1(i).ForeColor

=

RGB(255,

0,

255)

Case

6

Label1(i).BackColor

=

RGB(0,

0,

255)

Label1(i).ForeColor

=

RGB(255,

0,

0)

Case

7

Label1(i).BackColor

=

RGB(160,

32,

240)

Label1(i).ForeColor

=

RGB(95,

223,

15)

Case

8

Label1(i).BackColor

=

RGB(192,

192,

192)

Label1(i).ForeColor

=

RGB(63,

63,

63)

Case

9

Label1(i).BackColor

=

RGB(255,

255,

255)

Label1(i).ForeColor

=

RGB(0,

0,

0)

End

Select

Next

End

Sub

首先,页面1中用表单提交数据你要查询的数据

代码参考:<form action="对应的servlet类" metohd="post" name="form1">

接着,建立一个selvet类,继承HttpServlet,在selvet类的doPost()方法里写入查询数据库的代码,主要利用request来获取页面1中的参数,通过reponse来给页面2传输数据库查询的结果

代码参考:

Connection con=null

Statement stmt=null

ResultSet rs=null

String name=request.getParameter("name")

Class.forName("oracle.jdbc.driver.OracleDriver")

con = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:test1", "test","stst")

stmt = conn.createStatement()

rs = stmt.executeQuery("select ename,empno,deptno from emp where empno like \'"+name+"')

reponse.setContentType("text/htmlcharset=GB2312")

PrintWriter out=response.getWritertr()

out.println("<html><body>")

out.print("<table border>")

out.print("<tr><td colspan=8 align=center>用户数据</td></tr>")

out.print("<tr>")

while(rs.next)

{

our.print("<tr>")

our.print("<td>"+rs.getString("ename")+</td>)

our.print("<td>"+rs.getString("emono")+</td>)

our.print("<td>"+rs.getString("depno")+</td>)

our.print("</tr>")

}

out.print("</tr>")

out.print("</table>")

out.print("</body></html>")

out.close()

rs.close()

stmt.close()

con.close()

源文件是下载不了的,只能下载swf文件。

最简直的方法是:

浏览器的“工具---internet选项----浏览历史记录设置----查看文件”,去文件夹里面找


需要做网站?需要网络推广?欢迎咨询客户经理 13272073477