我要将程序上print出的数据保存到文件怎么办? 文件名叫做courses。
具体的控件名称: 文本框:txtid 大组合框:cboname 小组合框:cbocredit
中间的图形框:picout 将课程添加到数组:cmdadd 保存数组到文件:cmdsave
Dim n() As String, i As Long
Dim StrOut As String
Private Sub cmdadd_Click()
ReDim Preserve n(i) As String
If i > 0 Then
For j = 0 To UBound(n)
If cboname.Text = n(j) Then
MsgBox ("已有课程,勿重复添加")
Exit Sub
End If
Next
End If
n(i) = cboname.Text
cboname.AddItem n(i)
i = i + 1
End Sub
Private Sub cmdsave_Click()
Open App.Path & "\courses.txt" For Output As #1
Print #1, StrOut
Close #1
End Sub
Private Sub picout_Click() '假设你输出到pic用的是这个事件
StrOut = StrOut & Txtid.Text & " " & cboname & " " & cbocredit & vbCrLf
picout.Print Txtid.Text & " " & cboname & " " & cbocredit
End Sub
您好 请问你是做过这个程序 还是说你是计算机专业的?
追答后者
追问您好,我依葫芦画瓢想增添一个 “编号重复,勿重复添加” 但是不行,我该怎么办啊。。 是 编号哦