Open CommonDialog1.FileName For Input As #1. Do. If EOF(1) Then Exit Do. Line Input #1, Lstr. Text1.Text = Text1.Text + Lstr + Chr(13) + Chr(10) Loop. Close #1. Exit Sub. Close #1. End.
若CDROM 沒有光碟片,也會回傳true。 要用Drive 物件的IsReady來偵測. Dim fs As New FileSystemObject Private Sub Drive1_Change() Dim drv As Drive Set drv = fs.GetDrive(Drive1.Drive) If (Not drv.IsReady) Then MsgBox "Drive is not ready!"