VB编程题目

2024-11-10 05:23:49
推荐回答(2个)
回答1:

窗体上添加2个文本框和1个按钮,文本框用来显示2个同学名字
Private
Sub
Command1_Click()
'交换名字

Dim
s
As
String

s
=
Text1.Text

Text1.Text
=
Text2.Text

Text2.Text
=
s
End
Sub

回答2:

题目:窗体中有若干控件,单击其中的一个按扭cmdput时,
' 执行如下的事件过程,该过程的功能是把数据输出到指定的文件中.

'请在【?】处填入正确的内容

'-------------------------------------------------------
'
'**********SPACE**********
Private Type student
Number As String
Name As String
End Type
Private Sub cmdput_click()
Dim Title As String
Dim Str1 As String
Dim str2 As String
Dim stu As Student
Dim i As Integer
Open App.Path & "\student.dat" For Random As #1 Len = Len(stu)

Title = "写记录到随机文件"
Str1$ = "请输入学生号"
str2$ = "请输入学生名"
For i = 1 To 5
'**********SPACE**********
stu.Number = InputBox(Str1$, Title$)
stu.Name = InputBox$(str2$, Title$)
Put #1, i, stu
Next i
'**********SPACE**********
Close #1
End Sub