'修改之后
Private Type employee
  empno As Integer
  name As String * 10
  address As String * 10
End Type
Dim Emp As employee'此句提前到此处
Private Sub Command1_Click()
Dim fag As Integer
Dim n As Integer
Open "d:\a.dat" For Random As #1 Len = Len(Emp)
Title$ = "些记录到随机文件"
str1$ = "请输入雇员号"
str2$ = "请输入雇员名"
str3$ = "请输入雇员地址"
Do
  Emp.empno = InputBox(str1$, Title$)
  Emp.name = InputBox(str2$, Title$)
  Emp.address = InputBox(str3$, Title$)
  n = n + 1
  Put #1, n, Emp
  answer = MsgBox("您还要输入吗", 20, Title$)
  fag = answer
Loop While fag = 6
Close #1
End Sub
Private Sub Command2_Click()
n = Val(InputBox("请输入你要找的雇员号", ""))
Open "d:\a.dat" For Random As #1 Len = Len(Emp)
Get #1, n, Emp
Text1.Text = Str$(Emp.empno) + Emp.name + Emp.address
Close #1
End Sub