下列事件过程的功能是:建立一个名为Data1的随机文件,存放角度值及这些角度的正弦函数值和余弦函

23 查阅

下列事件过程的功能是:建立一个名为Data1的随机文件,存放角度值及这些角度的正弦函数值和余弦函数值,角度为1,2,3,…,90。请在空白处填入适当的内容,将程序补充完整( )。

Private Type Ang

K As Integer

Sinx As Single

Cosx As Single

End Type

Dim Ksc As Ang

Private Sub Form_Click()

Dim Y As Single

Dim i As Integer

Dim Ksc As Ang

Open______

Y=3.14159/180

For i=1 To 90

Ksc.K=i

Ksc.Sinx=Sin(i*Y)

Ksc.Cosx=Cos(i*Y)

Next i

Close #2

End Sub

A...\Data1.txtFor Random As #1 Len=10 Put#1,i,Ksc

B...\Data1.txtFor Random As #1 Len=10 Put#1,Y,Ksc

C...\Data1.txtFor Random As #1 Put#1,i,Ksc

D...\Data1.txtFor Random As #1 Put#1,Y,Ksc

参考答案:

A解析:分析程序,程序要将角度值及这些角度的正弦函数值和余弦函数值存入Data1文件中。因此,应先打开Data1文件,因为Data1文件是随机文件,要新建并写入信息,所以使用Random方式打开文件。这里给随机文件指定长度为10,所以第1个空白处应填"..\Data1.txt"For Random As #1 Len=10。要向随机文件中写入信息,应用Put语句,因此第2空应填Put #1,i,Ksc。

计算机二级