程序编码

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

第十五页2.2.3 综合应用题

Private Sub Command1_Click()

Dim a()

n = Val(InputBox("请输入一个整数"))

ReDim a(n, n)

Call yang(a(), n)

End Sub

Private Sub yang(a(), n)

For i = 1 To n

For j = 1 To i

If i = j Or j = 1 Then

a(i, j) = 1

Else

a(i, j) = a(i - 1, j - 1) + a(i - 1, j)

End If

Print Tab((j * 1) * 6 + 1); a(i, j);

Next j

Print

Next i

End Sub

第二十七页第九套基础操作题2

Private Sub Form_Click()

lable1.BackStyle = 1

lable1.BorderStyle = 0

lable2.BackStyle = 0

lable2.BorderStyle = 1

End Sub

第十八页第一套综合应用题

Option Explicit

Sub putdata(t_FileName As String, T_Str As Variant) Dim sFile As String

sFile = "\" & t_FileName

Open App.Path & sFile For Output As #1

Print #1, T_Str

Close #1

End Sub

Function isprime(t_I As Integer) As Boolean

Dim J As Integer

isprime = False

For J = 2 To t_I / 2

If t_I Mod J = 0 Then

Exit For

Next J

If J > t_I / 2 Then

isprime = True

End Function

Private Sub Cmd1_Click() Dim i As Integer

Dim temp As Long

temp = 0

If Op2.Value Then

For i = 200 To 400

If isprime(i) Then

temp = temp + i

End If

Next

Else

For i = 100 To 200

If isprime(i) Then

temp = temp + i

End If

Next

End If

Text1.Text = temp

End Sub

Private Sub Cmd2_Click() putdata "\out.txt", Text1.Text End Sub

基本操作题2

Private Sub Cmd1_Click()

Text2.Text = Text1.Text

End Sub

Private Sub Form_Load()

Text1.Text = ""

Text2.Text = "" (必须将两个文本框设置为空文本框,才与图相符)

End Sub

简单应用题1

Option Base 1 (数组下标下界从1开始)

Private Sub Command1_Click()

Dim a(30) As Integer

Dim max As Integer

Randomize

For i = 1 To 30

a(i) = Int(Rnd * 1001) (产生0—1000之间的随机数)

Next i

max = a(1) (变量max的初值应为数组的首元素值)

For i = 2 To 30

If a(i) > max Then

max = a(i)

End If

Next i

Print max

End Sub

简单应用题2

Sub savedate()

Open App.Path & "\" & "outtxt.txt" For Output As #1

Print #1, Text1.Text

Close #1

End Sub

Function fun() (题目中要求:计算能被5或7整除的整数个数的操作在过程fun中实现)Dim i As Integer, s As Integer

s = 0

For i = 0 To 1000

If i Mod 5 = 0 Or i Mod 7 = 0 Then

s = s + 1

End If

Next i

End Function

Private Sub Command1_Click() d = fun()

Text1.Text = d

Savedate (保存数据)

End Sub

第29套

简单应用题1

Private Sub Command1_Click() If Option1.Value = True Then Text1.FontName = "宋体"

End If

If Option2.Value = True Then Text1.FontName = "隶书"

End If

If Check1.Value = 1 Then

Text1.FontUnderline = True End If

If Check2.Value = 1 Then

Text1.FontItalic = True

End If

End Sub

相关文档
最新文档