|
电脑技术类资料大集合 |
|
[图文并茂]常用电脑资料速... |
|
关于系统安装,启动,卸载... |
|
[原创:图文教程]批量的动... |
|
216个电脑知识和实用问题解... |
|
电脑故障以及解决百科全书... |
|
Windows系统常见问题处理大全 |
|
windows xp 服务的最佳化说明 |
|
电脑报精华(申请加精) |
|
整理的常用VB问答 |
|
免费黄色电影,免费小电影,... |
|
电脑技术类资料大集合 |
|
电脑故障以及解决百科全书... |
|
关于系统安装,启动,卸载... |
|
[图文并茂]常用电脑资料速... |
|
破解互联星空(方法100%有... |
|
玩转电脑技巧全书 |
|
Windows十二种常用密码破解法 |
|
电脑报精华(申请加精) |
|
电脑实用小技巧!!!(不... |
| 整理的常用VB问答 |
| 作者 rian 查看 589 发表时间 2006/10/3 10:13 【论坛浏览】 |
![]() 图片 更多精彩内容 欢迎登入http://hi.baidu.com/softrain 进行查看 ^_^ Private Function isprime(a As Integer) As Boolean Dim flag As Boolean flag = True b% = 2 Do While b% <= Int(a / 2) And flag If Int(a / b%) = a / b% Then flag = False Else b% = b% + 1 End If Loop isprime = flag End Function +++++++以下黑体字部分是程序中没有的,需要自己被充+++++++ Private Sub C1_Click() Dim i As Integer i = 18000 Do i = i - 1 Loop Until isprime(i) Text1.Text = i End Sub Private Sub C2_Click() Open "out5.txt" For Output As #1 Print #1, Text1.Text Close #1 End Sub Private Sub COMEXIT_Click() End End Sub Private Sub COMSTART_Click() Dim g As Single, N As Integer, S As Single myfile1 = App.Path & "\" & "grade.DAT" myfile2 = App.Path & "\" & "average.dat" Open myfile1 For Input As #1 Open myfile2 For Output As #2 Do While Not EOF(1) Input #1, g N = N + 1 S = S + g Loop Close #1 S = S / N Write #2, S Close COMSTART.Caption = "完成" COMSTART.Enabled = False End Sub 图片附件: f178a701721efd061d95839c.jpg 2006/10/3 10:54, 56 B, 下载次数: 0 ![]() 图片 Option Explicit Private Sub Command1_Click(Index As Integer) If Index = 0 Then If Val(Label3(0).Caption) > 1 Then Command1(0).Enabled = True Label3(0).Caption = Label3(0).Caption - 1 Else If Val(Label3(0).Caption) = 1 Then Label3(0).Caption = Label3(0).Caption - 1 End If Command1(0).Enabled = False End If Else If Val(Label3(1).Caption) > 1 Then Command1(1).Enabled = True Label3(1).Caption = Label3(1).Caption - 1 Else If Val(Label3(1).Caption) = 1 Then Label3(1).Caption = Label3(1).Caption - 1 End If Command1(1).Enabled = False End If End If If Val(Label3(0).Caption) > Val(Label3(1).Caption) Then picSmile(0).Visible = True picCry(0).Visible = False picCry(1).Visible = True picSmile(1).Visible = False Else If Val(Label3(0).Caption) < Val(Label3(1).Caption) Then picCry(0).Visible = True picSmile(0).Visible = False picSmile(1).Visible = True picCry(1).Visible = False Else picSmile(0).Visible = True picCry(0).Visible = False picSmile(1).Visible = True picCry(1).Visible = False End If End If End Sub Private Sub Command2_Click(Index As Integer) If Index = 0 Then Label3(0).Caption = Label3(0).Caption + 1 Command1(0).Enabled = True Else: Label3(1).Caption = Label3(1).Caption + 1 Command1(1).Enabled = True End If If Val(Label3(0).Caption) > Val(Label3(1).Caption) Then picSmile(0).Visible = True picCry(0).Visible = False picCry(1).Visible = True picSmile(1).Visible = False Else If Val(Label3(0).Caption) < Val(Label3(1).Caption) Then picCry(0).Visible = True picSmile(0).Visible = False picSmile(1).Visible = True picCry(1).Visible = False Else picSmile(0).Visible = True picCry(0).Visible = False picSmile(1).Visible = True picCry(1).Visible = False End If End If End Sub Private Sub Form_Load() picSmile(0).Visible = True picSmile(1).Visible = True Command1(0).Enabled = False Command1(1).Enabled = False End Sub 图片附件: 的.jpg 2006/10/3 10:55, 66 B, 下载次数: 0 ![]() 图片 图片附件: d d d.jpg 2006/10/3 10:56, 27 B, 下载次数: 0 ![]() 图片2 第一部分,窗体程序部分: Dim a(100) As Integer Private Sub Cmd1_Click() Open App.Path & "\in.txt" For Input As #1 Text1.Text = "" For i = 1 To 100 Input #1, a(i) Text1.Text = Text1.Text & a(i) & Space(1) Next i Close #1 End Sub Private Sub Cmd2_Click() Text1.Text = "" s = 0 For i = 1 To 100 If a(i) Mod 2 <> 0 Then Text1.Text = Text1.Text & a(i) & Space(1) s = s + a(i) End If Next putdata s End Sub 第二部分,模块程序部分:(如没有,需要自行添加一个标准模块) Sub putdata(ByVal a As Integer) Dim sFile As String sFile = "\out.txt" Open App.Path & sFile For Output As #1 Print #1, a; Close #1 End Sub 图片附件: 大幅度飞.jpg 2006/10/3 10:57, 67 B, 下载次数: 0 ![]() 图片 Private Sub C1_Click() Open App.Path & "\in7.txt" For Input As #1 Do While Not EOF(1) Input #1, mystring Text1.Text = mystring Loop Close #1 End Sub Private Sub C2_Click() Text1.Text = UCase(Text1.Text) End Sub Private Sub C3_Click() Open App.Path & "\out7.txt" For Output As #2 Print #2, Text1.Text Close #2 End Sub 图片附件: 阿呆发大水飞.jpg 2006/10/3 10:57, 51 B, 下载次数: 0 ![]() 图片 Private Function fun(a As Integer) As Integer s% = 0 For i% = 500 To 600 If Int(i% / a) = i% / a Then s% = s% + i% End If Next fun = s% End Function Private Sub C1_Click() If Op1.Value Then Text1 = fun(7) End If If Op2.Value Then Text1 = fun(3) End Sub Private Sub Form_Unload(Cancel As Integer) Open "out7.txt" For Output As #1 Print #1, Op1.Value, Op2.Value, Text1.Text Close #1 End Sub 图片附件: 阿呆发动发发发飞.jpg 2006/10/3 10:58, 44 B, 下载次数: 0 ![]() 图片 Private Sub C1_Click() Open App.Path & "\out7.txt" For Output As #2 Print #2, Text1.Text Close #2 End Sub Private Sub Form_Load() Open App.Path & "\in7.txt" For Input As #1 Do While Not EOF(1) Input #1, mystring Text1.Text = Text1.Text + mystring Loop Close #1 Text1.Text = "计算机等级考试" + Text1.Text End Sub 图片附件: 哦哦哦哦哦哦哦.jpg 2006/10/3 10:59, 45 B, 下载次数: 0 ![]() 图片 Private Sub C1_Click(Index As Integer) Select Case Index Case 1 Timer1.Enabled = False Case 0 Timer1.Enabled = True End Select End Sub Private Sub Form_Load() End Sub Private Sub Timer1_Timer() Text1.Text = Text1.Text + 1 End Sub 图片附件: 平平平平平平平.jpg 2006/10/3 11:01, 39 B, 下载次数: 0 ![]() 图片 Option Base 1 Dim Arr1(20) As Integer Dim Arr2(20) As Integer Dim Sum As Integer Sub ReadData1() Open App.Path & "\" & "datain1.txt" For Input As #1 For i = 1 To 20 Input #1, Arr1(i) Next i Close #1 End Sub Sub ReadData2() Open App.Path & "\" & "datain2.txt" For Input As #1 For i = 1 To 20 Input #1, Arr2(i) Next i Close #1 End Sub Sub WriteData(Filename As String, Num As Integer) Open App.Path & "\" & Filename For Output As #1 Print #1, Num Close #1 End Sub Private Sub C1_Click() ReadData1 ReadData2 End Sub Private Sub C2_Click() Dim arr3(20) As Integer Sum = 0 For i = 1 To 20 arr3(i) = Arr1(i) \ Arr2(i) Sum = Sum + arr3(i) Next Print Sum End Sub Private Sub C3_Click() WriteData "dataout.txt", Sum End Sub 图片附件: iiiiiiiiii.jpg 2006/10/3 11:01, 56 B, 下载次数: 0 ![]() 图片 Private Sub Timer1_Timer() a = a + 1 If a > 6 Then a = 1 End If Select Case a Case 1 P1.Picture = LoadPicture("黄灯.ico") Case 2, 3 P1.Picture = LoadPicture("红灯.ico") Case 4, 5, 6 P1.Picture = LoadPicture("绿灯.ico") If b Then Timer2.Enabled = b End Select End Sub Private Sub Timer2_Timer() If (a < 4) And (P2.Left > P1.Left And P2.Left < P1.Left + P1.Width) Or P2.Left <= 100 Then Timer2.Enabled = False Else P2.Move P2.Left - 10, P2.Top, P2.Width, P2.Height End If End Sub 图片附件: 大水法发达的发.jpg 2006/10/3 11:00, 43 B, 下载次数: 0 ![]() 图片 Private Sub C1_Click() If Text1.Text = "123456" Then Text1.Text = "口令正确" Text1.PasswordChar = "" Else Text2.Text = Text2.Text - 1 If Text2.Text > 0 Then MsgBox "第" & (3 - Text2.Text) & "次口令错误,请重新输入" Else MsgBox "3次输入错误,请退出" Text1.Enabled = False End If End If End Sub 图片附件: 320d5ae797debc2eb9382095.jpg 2006/10/3 10:53, 43 B, 下载次数: 0 ![]() 图片 |
| 序号 | 评论者 | 共有评论 10 【论坛浏览】 【发表评论】 | 评论时间 | |||
| 1 | zmfet | 虽然不太懂VB,但图文并茂,不失为一篇好文章 | 2006/10/3 11:28 | |||
| 2 | rian |
是我们考试试卷哦 [s:141] |
2006/10/3 11:45 | |||
| 3 | lsyann | 路过,回个…… | 2006/10/3 15:15 | |||
| 4 | 片枫2006 | 这是全国计算机二级的vb试卷嘛? 好像没这么难哦,偶去年4月考了,很轻松就拿了个优秀。 |
2006/10/4 07:44 | |||
| 5 | momo007 | 学习学习 辛苦楼主了 | 2006/10/5 11:32 | |||
| 6 | rian |
不是拉 那个有这么难么? ——是自己收集到的一些题目 |
2006/10/6 04:54 | |||
| 7 | chnf117 | 天书一样!看不懂的说! | 2006/10/6 06:50 | |||
| 8 | luckerer | 楼主好强~谢谢了 | 2006/10/6 17:32 | |||
| 9 | iproffice | 图文并茂的帖子最容易看懂,很实用的教程,我又要学程序设计了... | 2006/10/7 04:27 | |||
| 10 | seraph | 哈哈,我也来顶一把,虽然不太懂!~~ | 2006/10/7 08:14 | |||
共有评论数 10 每页显示 10
|
||||||