1、APPENDappendAppend关闭所有已经打开的文件,应使用语句_。CLOSEcloseClose如果要将变量a在过程中定义为静态的整型变量,应使用的语句是_。static a%static a as integerStatic a%Static a As IntegerMsgBox函数的返回值的类型为_。数值型文本框的默认属性是_。TexttextTEXT标签控件的默认属性是_。CAPTIONCaptioncaption【程序说明】窗体上已建立命令按钮Command1(开始)、Command2(结束)和文本框Text1,Text1中输入字符个数不得超过100个。开始运行时,“结束”命令
2、按钮不能响应;按“开始”命令按钮后,将文本框中的字符按其ASCII码值由小到大顺序从左到右重新排列,并在窗体上输出重新排列后的字符串,同时“结束”命令按钮能响应,“开始”按钮不能响应。Private Sub Command1_Click() Dim n As Byte, i As Byte, j As Byte, p As Byte Dim a(100) As String * 1, str1 As String, t As String str1 = Text1.Text: n = Len(str1) For i = 1 To n:_: Next i For i = 1 To n - 1 p
3、 = i For j = i + 1 To n If a(p) a(j) Then_ Next j If p i Then t = a(i): a(p) = t Print a(i);: _ Command1.Enabled = FalseEnd SubPrivate Sub Command2_Click() EndPrivate Sub Form_Load() Command2.Enabled = False【空 1】 错误【学生答案】【参考答案】False=【空 2】 错误Date【空 3】 错误CommonDialog1.Color【空 4】 错误m1【程序说明】文件c:a1.dat中存
4、放若干个学生信息的记录(行),按Command1按钮后,查找文件中姓名与输入姓名相同的记录,找到则删除该记录。 Dim bs As String,cs As String Open c:a1.dat For Input As #1temp.dat bs = InputBox(输入学生姓名 Do While Not Eof(1) Line Input #1, cs if InStr(cs, Trim(bs) = _Then print #2,cs Loop Close #1: Close #2 Kill Name _无For Output As #2 As 【程序说明】以下是一个简化了的猜数游戏
5、程序,自动生成一个小于100的随机正整数与您用输入对话框输入的数进行对比,猜中后输出相关信息,过程结束。单击窗体则开始猜数,如要终止Visual Basic程序运行可以按Ctrl+Break组合键。Private Sub Form_Click() Dim r As Integer, x As Integer, i As Integer Randomize : r =_ For i = 1 To 10 x = Val(InputBox(请输入一个整数:) If x 太大了,请继续猜! If x = r Then Print 猜中了!共猜了 + _+ 次 If i = 5 Then Print 太
6、棒了! Else Print 加油! End If1【程序说明】右击窗体则打开Windows自带的计算器“C:windowscalc.exe”;单击“退出”按钮时将右击窗体的次数写入磁盘文件。_Private Sub Form_MouseUp(Button As Integer, Shift As Integer, _ X As Single, Y As Single) If Button = 2 Then n = n + 1: Shell _C: For _ Print #1,n: Close #1Dim n As Integerwindowscalc.exeOutputEnd【程序说明】本
7、程序求3100之间的所有素数(质数)并统计个数;同时将这些素数从小到大依次写入顺序文件e:dataout.txt;素数的个数显示在窗体Form1上。 Dim coun As Integer, flag As Boolean Dim t1 As Integer, t2 As Integer coun = 0 For t1 = 3 To 100 flag = True For t2 = 2 To Int(Sqr(t1) If _then flag = False Next t2 coun = coun+1 Write #1, t1 Next t1Open e:dataout.txt For Output As #1t1 Mod t2 = 0If flag ThenPrint coun【程序说明】窗体上有两个命令按钮:Command1(显示)和Command2(退出)。下列程序运行时,“显示”按钮能响应,“退出”按钮不能响应;单击“显示”按钮后,在窗体上显示一个用字符“*”组成的5层的金字塔,同时“显示”按钮不能响应,“退出”按钮能响应。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1