急!如何在text控件中显示打开的文本
请问大家,如果将准备打开的txt文件在VB文本框text控件显示出来?谢谢!
'下面是我的一个程序中“加载”按钮的代码
Private Sub cmdLoad_Click()
Dim FileName As String
Dim FileNum As Integer
Dim strData As String
FileName = OpenFile(Me.hWnd, "Mail List Files|*.txt|All Files|*.*", 0)
If FileName <> "" Then
txtMailList = ""
FileNum = FreeFile
Open FileName For Input As #FileNum
While Not EOF(FileNum)
Line Input #FileNum, strData
txtMailList.Text = txtMailList.Text & strData & vbCrLf
Wend
Close #FileNum
If Right(txtMailList, 2) = vbCrLf Then
txtMailList.Text = Left(txtMailList.Text, Len(txtMailList.Text) - 2)
End If
End If
End Sub