搜索
您的当前位置:首页VB 程序设计题

VB 程序设计题

来源:爱问旅游网
跳动的小球

Dim t As Integer

Private Sub Command1_Click() t = Val(Combo1.Text) Timer1.Enabled = True Timer1.Interval = 200 End Sub

Private Sub Command2_Click() Unload Me End Sub

Private Sub Form_Load() Private Sub Command2_Click() Dim i As Integer If Text1.Text = \"\" Or (Not IsNumeric(Text1.Text)) Then For i = 10 To 100 Label1.Caption = \"空字符串或非数字字符!请重新输入 \" Combo1.AddItem i Text1.Text = \"\" Next ElseIf Val(Text1.Text) > r Then Shape1.Visible = False Label1.Caption = Text1.Text & \"大了,已猜了\" & s & \"次Shape2.Visible = False \" s = s + 1 Combo1.Text = 10 Text1.Text = \"\" Label1.Caption = \"选择跳动区域\" ElseIf Val(Text1.Text) < r Then End Sub Label1.Caption = Text1.Text & \"小了,已猜了\" & s & \"次Private Sub Timer1_Timer() \" s = s + 1 t = t - 1 Text1.Text = \"\" Label1.Caption = \"倒计时:\" & t & \"秒\" Else If t Mod 2 = 0 Then Label1.Caption = \"恭喜您答对了!共猜了\" & s & \"次 \" Shape1.Visible = True Text1.Locked = True Shape2.Visible = False Command1.Enabled = True Else Command2.Enabled = False Shape1.Visible = False End If Shape2.Visible = True End Sub End If If t = 0 Then Private Sub Command3_Click() Timer1.Enabled = False Unload Me t = MsgBox(\"时间到!\消息框\") End Sub Shape1.Visible = False Shape2.Visible = False Private Sub Form_Load() End If Text1.Text = \"\" Label1.Caption = \"请按下“开始”按钮启动游戏\" Command2.Enabled = False End Sub End Sub 控件名 属性名 属性值 对象 属性名称 属性值 Form Caption 跳动的小球 Form Caption 猜数游戏 Combo1 Text1 空 Label Caption 请按下“开始按钮启动游戏” Frame1 Caption 跳动区域 TextBox1 Text 空 Visible True Shape1、Shape2 Command1 Caption 开始 BackColor Command2 Caption 确认 BackStyle 1.Opaque Command3 Caption 退出 Shape 2.Circle Command1 Caption 开始 查询器 Command2 Caption 退出 猜数游戏

Dim r, s As Integer

Private Sub Command1_Click()

Label1.Caption = \"请输入一个100以内的正整数\" Randomize

r = Int((100 * Rnd) + 1) s = 1

Text1.Locked = False

Command1.Enabled = False Command2.Enabled = True End Sub

通用对话框的使用 Dim yn As Integer

Private Sub Command1_Click()

CD1.Filter = \"文档(*.doc;*.rtf;*.txt)|*.doc;*.ref;*.txt|所有文件(*.*)|*.*\" CD1.Action = 1

Label1.Caption = \"打开\" + CD1.FileName Text1.Text = \"\"

Open CD1.FileName For Input As #1 Do While Not EOF(1)

Line Input #1, inputdata

Text1.Text = Text1.Text + inputdata + vbCrLf Loop Close #1 End Sub

Private Sub Command2_Click() CD1.FileName = \"default.txt\" CD1.DefaultExt = \"txt\" CD1.Action = 2

Label1.Caption = \"保存\" + CD1.FileName Open CD1.FileName For Output As #1 Print #1, Text1.Text Close #1 End Sub

Private Sub Command3_Click() CD1.Flags = 3 CD1.Action = 4

Label1.Caption = \"为文件\" + CD1.FileName + \"设置字体\" Text1.FontName = CD1.FontName Text1.FontSize = CD1.FontSize Text1.FontBold = CD1.FontBold Text1.FontItalic = CD1.FontItalic

Text1.FontStrikethru = CD1.FontStrikethru Text1.FontUnderline = CD1.FontUnderline Text1.ForeColor = CD1.Color End Sub

Private Sub Command4_Click()

yn = MsgBox(\"在退出之前您的文件保存了吗?\提示\") If yn = 6 Then Unload Form1 End If End Sub 控件名 属性 属性值 Form1 Caption 通用对话框的使用 CommonDialog1 Label1 TextBox1 Command1 Command2 Command3 Command4 名称 CD1 Caption 请选择有段按钮进行操作Name Text1 Multiline True ScrollBars 2-Vertical Caption 打开文件 Caption 保存文件 Caption 更改字体 Caption 退出

Private Sub Adodc1_MoveComplete(ByVal 文件拷贝 adReason As ADODB.EventReasonEnum, ByVal Pr Private Sub Command1_Click() pError As ADODB.Error, adStatus As Text2.Text = Text1.Text ADODB.EventStatusEnum, ByVal pRecordset As Text1.Text = \"\" ADODB.Recordset) Label1.Caption = \"左面文本框的文字已拷贝到右面的文Adodc1.Caption = 本框\" Adodc1.Recordset.AbsolutePosition & \"/\" & Command2.Enabled = True Adodc1.Recordset.RecordCount End Sub End Sub Private Sub Command1_Click() Private Sub Command2_Click() If Text1.Text <> \"\" Then Unload Me Adodc1.RecordSource = \"select * from 基本信End Sub 息 where 专业=‘\" & Text1.Text & \"'\" Adodc1.Caption = Text1.Text Private Sub Form_Load() Else Label1.Caption = \"请在左面的文本框输入文字,然后按下 Adodc1.RecordSource = \"select * from 基本信确认按钮\" 息\" Text2.Locked = True Adodc1.Caption = \"全部专业\" Command2.Enabled = False End If text1.text=\"\" Adodc1.Refresh End Sub End Sub 对象 属性名称 属性值 Private Sub Form_Activate()

Form1 Caption 文本拷贝 Text1.SetFocus

TextBox1 MultiLine True End Sub

ScrollBars 2-Vertical

Private Sub Form_Load() TextBox2 MultiLine True Dim link$ ScrollBars 2-Vertical Adodc1.ConnectionString=

Command1 Caption 确认 \"provider=microsoft.jet.oledb.4.0\" + \"data

Command2 Caption 退出 source=\" + App.Path + \"/\" + \"学生数据库2.mdb\"

Enabled False Adodc1.CommandType = adCmdUnknown

Text1.Text = \"\" Adodc1.Caption = \"\" End Sub 控件名 属性名 属性值 Form1 Label1 Datagrid1 Command1 caption Caption Datasource caption 查询器 请输入专业名称 Adodc1 查询 学生基本信息浏览

Private Sub Command1_Click() Data1.RecordSource = \"基本信息\" Data1.Refresh

Data1.Caption = \"基本信息\"

Form1.Caption = \"学生基本信息浏览\" End Sub

Private Sub Command2_Click() Data1.RecordSource = \"成绩信息\" Data1.Refresh

Data1.Caption = \"成绩信息\"

Form1.Caption = \"学生成绩信息浏览\" End Sub 控件名 属性名 属性值 Command1 caption 基本信息 Command2 caption 成绩信息 Data1 Databasename E:\\学习\\VB\\vb考试 设计题\\学生数据库2.mdb MsflexgridDatasource Data1 1 Allowuserresizin3-flexresizebotg h fixedcols 0

美丽的电视发射塔 Dim i As Integer Dim j As Integer

Dim r As Byte, g As Byte, b As Byte

Private Sub Form_Click() Timer1.Interval = 0 Cls

End Sub

Private Sub Form_Load() 'backcolor=rgb(0,0,0) j = 0

DrawWidth = 1

PSet (ScaleWidth / 3, 1000) ForeColor = RGB(0, 255, 0) For i = 1 To 50 Step 5 DrawWidth = i

Line -Step(0, ScaleHeight / 10) Next i

DrawWidth = 1 FillStyle = 6

FillColor = ForeColor

Circle (ScaleWidth / 3, 2000), 300, , , , 0.5 End Sub

Private Sub Timer1_Timer() FillStyle = 1 DrawStyle = 2 r = 255 * Rnd g = 255 * Rnd b = 255 * Rnd j = j + 1

Circle (ScaleWidth / 3, 1000), 300 * j, RGB(r, g, b) If j = 10 Then j = 0

End Sub 控件名 属性名 属性值 Form1 Caption 图形控件的使用 AutoreDraw True Timer1 Interval 100

几何图案

Private Sub Form_Click() For i = 1 To 5

Print Spc(10 - (10 - i)); String(10, \"◆\") Next i End Sub

风景画册

Private Sub HScroll1_Change() i = HScroll1.Value Image1.Picture=

LoadPicture(App.Path& \"\\o\\\"&i&\".gif\") End Sub

1、VB程序有:解释运行程序 编译巡行方式 2、VB是一种,可视化编程、面向 对象的程序设计。结构化程序设计 语言 3、工程文件(Vbp)窗体文件(frm) 标准模块文件(bas) 4、基本设计机制:为对象时间编写事件过程,在事件中响应中填写改变对象 的属性的语句,调用对象的方法完成 特定功能 5、类模块(Cls) 6、工程是模块的集合,一个工程可 以包含多个模块 7、窗体有自己的属性、事件和方法 用时钟控制输出

Private Sub Command1_Click()

Timer1.Enabled = True Private Sub Combo1_Click() Timer1.Interval = 2000 If Combo1.Text = \"学号\" Then Command1.Enabled = False Frame1.Enabled = True End Sub Frame2.Enabled = False Private Sub Command2_Click() Frame3.Enabled = False Command3.Enabled = True End If Timer1.Enabled = False If Combo1.Text = \"年龄\" Then Command2.Enabled = False Frame1.Enabled = False End Sub Frame2.Enabled = True Private Sub Command3_Click() Frame3.Enabled = False Timer1.Enabled = True End If Command2.Enabled = True If Combo1.Text = \"专业\" Then Command3.Enabled = False Frame1.Enabled = False End Sub Frame2.Enabled = False Private Sub Command4_Click() Frame3.Enabled = True Timer1.Enabled = False End If End Sub End Sub Private Sub Timer1_Timer() Text1.Text = Text1.Text & Time & \" \" Private Sub Command1_Click() For i = 1 To 10 If Combo1.Text = \"学号\" Then n = Int(Rnd * 101)

Adodc1.RecordSource = \"select * from 基本信息 Text1.Text = Text1.Text & n & \" \" where 学号='\" & Text1 & \"'\" Next i End If Text1.Text = Text1.Text & Chr(13) & Chr(10) If Combo1.Text = \"年龄\" Then End Sub Adodc1.RecordSource = \"select * from 基本信息 where 年龄>=\" & Text2.Text & \"and 年龄<=\" & Text3.Text & \"\" 对象 属性名称 属性值 End If Form Caption 用时钟控制输出 If Combo1.Text = \"专业\" Then TextBox1 MultiLine True Adodc1.RecordSource = \"select * from 基本信息 ScrollBars 3-Both where 专业='\" & Combo2.Text & \"'\" Command1 Caption 开始 End If Command2 Caption 暂停 Adodc1.Refresh Enabled False End Sub Command3 Caption 继续 Private Sub Form_Load() Enabled False Combo1.AddItem \"学号\" Command4 Caption 结束 Combo1.AddItem \"年龄\"

Combo1.AddItem \"专业\"

Combo1.Text = \"\"

Combo2.AddItem \"计算机网络\" Combo2.AddItem \"软件工程\" Combo2.AddItem \"多媒体\" Combo2.Text = \"\"

Frame1.Enabled = False Frame2.Enabled = False Frame3.Enabled = False Adodc1.ConnectionString = \"Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=E:\\学习\\VB\\vb考试 设计题\\基本信息.mdb\" End Sub 对象 属性名称 属性值 Label1 Caption 请选择查询关键字 TextBox1 text 空 查询程序 TextBox2 Text 空 空 开始 按学号查询 按年龄查询 按专业查询 TextBox3 Text Command1 Caption Frame1 Caption Frame2 Frame3 Caption Caption

因篇幅问题不能全部显示,请点此查看更多更全内容

Top