vb随机点名器程序代码(vbs随机点名代码)

http://www.itjxue.com  2023-03-16 05:59  来源:未知  点击次数: 

如何用VB编一个随机点名册

不知道你要做什么。随机点名用Select Case 要命啊,输入64个Case,你不嫌麻烦?最好的办法是将姓名放入数据库然后随机读取。如果你对VB操作数据库不熟悉。给你个简单办法。

dim name(1 to 64) as String

Dim b As Single

'这里你将64个人名字放到数组name里例如

name(1)="张三"

name(2)=“李四”

………………

'然后生成随机数

Randomize

b = Int(Rnd() * 64) + 1

Text1.Text = nane(b)

一个VB随机点名的问题 程序如下

这一段

Dim Names As String

For i = 1 To 45

Names = Array(赵, 钱, 孙, 李, 周)

List1.AddItem Names

Next

改成

Dim Names

Dim i As Integer

Names = Array("赵", "钱", "孙", "李", "周")

For i = 0 To UBound(Names)

List1.AddItem Names(i)

Next

VB随机点名代码

'新建一个工程,在工具里面添加一个TEXT1和Command1,然后复制下面的代码

Dim

strInt(45)

As

String

Private

Sub

Command1_Click()

strInt(1)

=

"XXX"

strInt(2)

=

"SSS"

strInt(3)

=

"KKK"

i

=

Int(Rnd()

*

(1

-

45)

+

40)

If

i

1

And

i

45

Then

Text1.Text

=

strInt(i)

End

If

End

Sub

vb 制作随机点名器的源码,谁有啊?急……谢谢

一个listbox 默认名字为list1

一个commandbutton 默认名字为command1

一个textbox 默认名字为text1

代码如下:

Public go As Boolean

Private Sub Command1_Click()

go = Not (go)

start

End Sub

Private Sub Form_Load()

'窗体加载时随机添加姓名和学号

Randomize

Dim Num As String

Dim Names As String

For i = 1 To 45

Num = Int((99999 - 11111 + 1) * Rnd + 11111) '学号范围 99999-11111

Names = Chr(Int((-13000 + 15000 + 1) * Rnd + -13000)) Chr(Int((-13000 + 15000 + 1) * Rnd + -13000)) Chr(Int((-13000 + 15000 + 1) * Rnd + -13000)) '随机生成字符作为名字

List1.AddItem Num " " Names

Next

go = False

End Sub

Sub start()

On Error Resume Next

If List1.ListCount = 0 Then Exit Sub

If go = False Then Exit Sub

Do While go = True

p = Int((0 + List1.ListCount) * Rnd)

Text1.Text = List1.List(p)

DoEvents

Loop

End Sub

VB的不重复点名软件怎么做?

Dim Cx As Integer Private Sub Command1_Click() Randomize Dim a(1 To 10) As String a(1) = "小刘" a(2) = "小李" a(3) = "小马" a(4) = "小张" a(5) = "小秦" a(6) = "小熊" a(7) = "小黄" a(8) = "小兰" a(9) = "小周" a(10) = "小陈" Dim i As Integer sc: i = Int(10 * Rnd + 1) If i = Cx Then GoTo sc Cx = i Label1.Caption = a(i) End Sub

(责任编辑:IT教学网)

更多

推荐Flash动画文章