求帮做VB课程设计(打字游戏)
Dim h As Integer
Dim n As Integer
Private Function zi()
Randomize
If Form1.Option1.Value Then
a = Int((122 - 97 + 1) * Rnd + 97)
ElseIf Form1.Option2.Value Then
a = Int((90 - 65 + 1) * Rnd + 65)
ElseIf Form1.Option3.Value Then
a = Int((126 - 48 + 1) * Rnd + 48)
End If
zi = Chr(a)
End Function
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim b As Integer
Dim c As Integer
b = -1
c = -1
For i = 0 To Label1.Count - 1
If Label1(i).Caption = Chr(KeyAscii) Then
If Label1(i).Top > b Then
c = i
End If
End If
Next
If c > -1 Then
Image1.Top = Label1(c).Top
Image1.Left = Label1(c).Left
Image1.Visible = True
Label1(c).Top = -10
Label1(c).Caption = zi
h = h + 1
Label2.Caption = "当前得分:" & h
If Form1.Option4.Value Then
h = h + 1
ElseIf Form1.Option5.Value Then
h = h + 2
ElseIf Form1.Option6.Value Then
h = h + 3
End If
End if
If KeyAscii = 27 Then
If MsgBox("真的要退出吗", vbYesNo) = vbYes Then
MsgBox "您的得分" & h & "分", , "成绩"
Unload Form2
Form1.Show
End If
End If
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Image1.Visible = False
End Sub
Private Sub Form_Load()
Dim lu As String
lu = App.Path
If Right(lu, 1) <> "/" Then
lu = lu & "/"
End If
lu = lu & "3.jpg"
Image1.Picture = LoadPicture(lu)
h = 0
n = 0
For i = 0 To Label1.Count - 1
Label1(i).Top = 0 - 380 * (i + 1)
Label1(i).Caption = zi
Next
End Sub
Private Sub Timer1_Timer()
For i = 0 To Label1.Count - 1
If Form1.Option4.Value Then
If h > 100 Then
Label1(i).Top = Label1(i).Top + 80
Else
Label1(i).Top = Label1(i).Top + 40
End If
ElseIf Form1.Option5.Value Then
If h > 200 Then
Label1(i).Top = Label1(i).Top + 120
Else
Label1(i).Top = Label1(i).Top + 60
End If
ElseIf Form1.Option6.Value Then
If h > 300 Then
Label1(i).Top = Label1(i).Top + 160
Else
Label1(i).Top = Label1(i).Top + 80
End If
End If
If Label1(i).Top > 6525 Then
n = n + 1
Label3.Caption = "掉落个数:" & n
Label1(i).Top = -10
Label1(i).Caption = zi
End If
If n = 27 Then
If MsgBox("掉落的个数已经超过" & n & "个,是否重新开始", vbYesNo) = vbYes Then
MsgBox "您的得分:" & h & "分", , "成绩"
Unload Form2
Form1.Visible = True
Exit Sub
Else
MsgBox "您的得分" & h & "分", , "成绩"
End
End If
End If
Next
End Sub
VB课程设计!!要求能够随机生成20道数学计算题并对用户结果进行判断!
我以前也做过类似的程序,部分代码给你参考下.
Private Sub Form_Load()
Timer1.Enabled = True
Randomize (Timer)
Chufa(0) = 2: Chufa(1) = 4: Chufa(2) = 5: Chufa(3) = 8: Chufa(4) = 10: Chufa(5) = 16
Chufa(6) = 20: Chufa(7) = 32: Chufa(8) = 40
tm$ = "": Ckda$ = "": js = cssj * 60: jsj = js
If = 1 Then
For i = 1 To csts
js = Int(Rnd * 4)
If js = 0 Then fh = "+"
If js = 1 Then fh = "-"
If js = 2 Then fh = "×"
If js = 3 Then fh = "÷"
If fh = "+" Then
A = Int(Rnd * csnd * 10) + csnd * 10
B = Int(Rnd * csnd * 10) + csnd * 10
Ans(i) = A + B
End If
If fh = "-" Then
A = Int(Rnd * csnd * 10) + csnd * 10
B = Int(Rnd * csnd * 10) + csnd * 10
Ans(i) = A - B
End If
If fh = "×" Then
A = Int(Rnd * csnd * 3 + 2 * csnd)
B = Int(Rnd * csnd * 3) + 2 * csnd
Ans(i) = A * B
End If
If fh = "÷" Then
= Int(Rnd * 3 + 1)
B = + csnd - 1)
A = Int(Rnd * csnd * 10) + csnd * 10
Ans(i) = A / B
End If
tm$ = tm$ + "(" + Str(i) + ") " + Str(A) + fh + Str(B) + "=" + Chr(13) + Chr(10)
Ckda$ = Ckda$ + "(" + Str(i) + ") " + Str(A) + fh + Str(B) + "=" + Str(Ans(i)) + Chr(13) + Chr(10)
Next i
Text1 = tm$
End If
ll = Label1(0).Left: lw = Label1(0).Width: lh = Label1(0).Height: lt = Label1(0).Top
tw = Text3(0).Width
For i = 0 To 5
For j = 0 To 4
Label1(i * 5 + j).Top = lt + i * lh + 400: Label1(i * 5 + j).Left = ll + j * (lw + tw) + 300
Label1(i * 5 + j).Width = lw
Text3(i * 5 + j).Top = Label1(i * 5 + j).Top: Text3(i * 5 + j).Left = Label1(i * 5 + j).Left + lw
Label1(i * 5 + j).Caption = Str(i * 5 + j + 1) + ")"
Next j
Next i
If csts <> 30 Then
For i = csts To 29
Label1(i).Visible = False
Text3(i).Visible = False
Next i
End If
End Sub
VB 课程设计图像浏览器 怎么做的啊 谢谢
窗体上放dirvelistbox控件dirlistbox控件filelistbox控件image控件 label控件各一个
然后在窗体下写如下代码 程序运行后选择图片所在路径就可以在image内显示
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
mpath = File1.Path
If Right(mpath, 1) <> "" Then mpath = mpath + ""
mpath = mpath + File1.FileName
Form1.Image1.Picture = LoadPicture(mpath)
Label1 = mpath
End Sub
求VB课程设计代码文件,最好有报告及模板!VB初级者急用!谢谢!
ef x As Integer, ByRef y As Integer) As Integer
ADD = x + y
End Function
Private Function Multi(x As Integer, y As Integer) As Integer
Multi = x * y
End Function
Private Sub Command1_Click()
x = CInt(InputBox("请输入x的值:", "赋值"))
y = CInt(InputBox("请输入y的值:", "赋值"))
Sum = ADD(Int(x), Int(y))
Text1.Text = CStr(x) + "+" + CStr(y) + "=" + CStr(Sum)
End Sub
Private Sub Command2_Click()
x = CInt(InputBox("请输入x的值:", "赋值"))
y = CInt(InputBox("请输入y的值:", "赋值"))
cheng = Multi(Int(x), Int(y))
Text1.Text = CStr(x) + "*" + CStr(y) + "=" + CStr(cheng)
End Sub
另外,虚机团上产品团购,超级便宜
求一个VB课程设计,具体要求看说明.
简单的加法程序:
Private Sub Command1_Click()
Text3 = Val(Text1) + Val(Text2)
End Sub
Private Sub Command2_Click()
Text3 = Val(Text1) - Val(Text2)
End Sub
Private Sub Command3_Click()
If Text2 <> 0 Then
Text3 = Text1 / Text2
Else
MsgBox "除数不能为0", okonly, "提示"
End If
End Sub
Private Sub Command4_Click()
Text3 = Text1 * Text2
End Sub
帮我做个vb课程设计(算法演示器),好几天都没弄出来包括二维数组的各种数车方式,二维数组中最大元素及
动画演示 本系统由三部分组成:算法介绍、算法的动画演示、算法计算。
1. 算法介绍:实现二维数组的各种输出方式、二维数组中最大元素及所在下标的查找、二维数组的转置、插入排序法、冒泡法排序、选择排序法、归并排序法、快速排序法、shell排序法、折半查找、一元高次方程求解、数制转换等算法的介绍。
2. 算法的动画演示:用动画的方式介绍以上算法的执行步骤0。
3. 算法的计算:可对随机生成的数据进行算法的验证。
要求: 2.算法介绍:算法按类别归类,算法介绍采用图文并茂。
3. 算法的动画演示:要求动画制作直观形象,步骤中可以进行暂停操作。
4. 算法计算:要求对随机生成的数组使用过程完成上述算法程序设计。