•Private Sub command1_Click()
•'''不得删除本行注释
•Dim a As Integer, b As Double, i As Integer, n As Integer
•n = Val(Text1.Text)
•a = 0
•b = 0
•For i = 1 To n
•a = a + i
•b = b + a
•Next i
•Text2.Text = b
•End Sub
Private Sub Command1_Click()
'''不得删除本行注释
Dim i%, xh$, xm$
Open App.Path & "\\" & "Xhxm.txt" For Output As #1
For i = 1 To 3
xh = InputBox("请输入学号")
xm = InputBox("请输入姓名")
Write #1, xh, xm
Next i
Close #1
End Sub
Private Sub Command2_Click()
'''不得删除本行注释
Dim s as string
Open App.Path & "\\" & "Xhxm.txt" For Input As #2
Do While Not EOF(2)
Line Input #2, s
Text1.Text = Text1.Text & s & vbCrLf
Loop
Close #2
End Sub
Private Sub Command1_Click()
Dim n As Integer, i As Integer, s As Double
n = Val(Text1.Text)
s = 0
For i = 1 To n
s = s + i ^ 2
Next i
Text2.Text = s
End Sub
Private Sub Command1_Click()
‘”读取文件”按钮代码
'''不得删除本行注释
Dim st As String
Text1.Text = ""
Open App.Path & "\\" & “jmwb.txt" For Input As #1
While Not EOF(1)
Input #1, st
Text1.Text = Text1.Text + st + vbCrLf
Wend
Close #1
End Sub
Private Sub Command2_Click()
Dim s As String, co As String, c As String,
Dim n As Integer, i As Integer, p As Integer
s = Trim(Text1.Text)
n = Len(s)
co = ""
For i = 1 To n
c = Mid(s, i, 1)
p = Asc(c) + 5
co = co + Chr(p)
Next i
Text2.Text = co
End Sub
Private Sub Command1_Click()
Dim char As String * 1
char = Trim(Text1.Text)
If Not IsNumeric(char) Then
If (Asc(char) >= 65 And Asc(char) <= 90) Or _
(Asc(char) >= 97 And Asc(char) <= 120) Then
Label1.Caption = "输入的是字母"
Else: Label1.Caption = "输入的是其它符号"
End If
Else: Label1.Caption = "输入的是数字"
End If
End Sub
(课本有完整代码)
Private Sub Command1_Click()
Text1.Text = UCase(Text1.Tag)
End Sub
Private Sub Command2_Click()
Text1.Text = LCase(Text1.Tag)
End Sub
Private Sub Command3_Click()
Text1.Text = Text1.Tag
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
'对于文本框控件中输入的每次键盘按键弹起事件做一次文本内容保存
Text1.Tag = Text1.Text
'用Text1.Tag属性作为保存textbox控件文本内容的临时存储区
End Sub
Private Sub command1_Click()
''' 不得删除本行注释
Dim a As Integer, b As Integer, c As Integer
Dim max As Integer, min As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
max = a + b + Abs(a - b)
max = max / 2
min = a + b - Abs(a - b)
min = min / 2
max = max + c + Abs(max - c)
max = max / 2
min = min + c - Abs(min - c)
min = min / 2
Text4.Text = max
Text5.Text = min
End Sub
Private Sub Command1_Click()
Dim a As Integer
a = Val(Text1.Text)
If (a Mod 4 = 0 And a Mod 100 <> 0) Or a Mod 400 = 0 Then
Text2.Text = "闰年"
Else: Text2.Text = "非闰年"
End If
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub Text1_Change()
If Not IsNumeric(Text1.Text) Then
MsgBox "请输入数字!", 48, "输入的不是数字"
Command1.Enabled = False
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Else: Command1.Enabled = True
End If
Private Sub Command1_Click()
''' 不得删除本行注释
Dim i As Integer
For i = 1 To 200
If i Mod 3 = 0 And i Mod 7 = 0 Then
Text1.Text = Text1.Text + Str(i)
End If
Next
End Sub
Private Sub Command1_Click()
''' 不得删除本行注释
Dim sum As Single, i As Integer
Open App.Path & "\\" & "Jsdata.txt" For Input As #1
For i = 1 To 15
Input #1, Arr(i)
Next i
Close #1
If Op1 Then
T1.Text = Aaa
End If
If Op2 Then
T1.Text = Bbb
End If
End Sub
Private Sub Command1_Click()
''' 不得删除本行注释
Dim a As Integer
a = Val(Text1.Text)
Text2.Text = zh(a)
‘ zh过程在原本的程序代码中已经有了~直接可用
End Sub
(课本有完整代码)
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
Label1.Caption = Int(Rnd() * (b - a + 1) + a)
Label2.Caption = Int(Rnd() * (b - a + 1) + a)
Label3.Caption = Int(Rnd() * (b - a + 1) + a)
End Sub
Private Sub Command1_Click()
Dim s as string
Open App.Path & "\\" & "Bdata.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, s
Text1.Text = Text1.Text + s + Chr(13) + Chr(10)
Loop
Close #1
End Sub
Private Sub Command1_Click()
'''不得删改本行注释
Dim n As Integer
n = Val(Text1.Text)
If n < 100 Or n > 999 Then
MsgBox "请输入三位正整数", , "输入出错"
Else: Text2.Text = Int(n Mod 10)
Text3.Text = Int((n Mod 100) / 10)
Text4.Text = Int(n / 100)
End If
End Sub
Private Sub Command1_Click()
‘产生按钮的代码
i = List1.ListIndex
For i = 0 To 9
List1.AddItem Int(90 * Rnd + 10)
Next i
End Sub
Private Sub Command3_Click() ’清除按钮的代码
List1.Clear
List2.Clear
End Sub
Private Sub Command2_Click()
'''不得删改本行注释
Dim n As Double
i = List1.ListIndex
For i = 0 To List1.ListCount - 1
n = Val(List1.List(i))
If n Mod 2 = 1 Then
List2.AddItem n
List1.RemoveItem I ‘代码有误
End If
Next i
End Sub
Private Sub Command1_Click()
‘”读入数据”按钮代码
'''不得删除本行注释
Dim st As String
Text1.Text = ""
Open App.Path & "\\" & "yy.txt" For Input As #1
While Not EOF(1)
Input #1, st
Text1.Text = Text1.Text + st + vbCrLf
Wend
Close #1
End Sub
Private Sub Command2_Click()
'''不得删除本行注释
Dim x As String, y As String * 1, n As Integer, i As Integer, p As Integer
x = Trim(Text1.Text)
n = Len(x)
p = 0
For i = 1 To n
y = UCase(Mid(x, i, 1))
If y >= "A" And y <= "Z" Then
p = p + 1
End If
Next i
Label1.Caption = "共" & p & "个字母"
End Sub
Private Sub Command1_Click()
'''不得删除本行注释
Dim n As Integer, k As Integer, i As Integer
For n = 200 To 300
k = Int(Sqr(n))
For i = 2 To k
If n Mod i = 0 Then Exit For
Next i
If i > k Then List1.AddItem n
Next n
End Sub下载本文