-
Common Dialog Problem?
I have put a Munu Bar into my application with the following code in the File|Open Click Event:
Private Sub mnuOpen_Click()
Dim tFile As String
CommonDialog1.DialogTitle = "Open File"
CommonDialog1.Filter = "Word Documents (*.doc)|*.doc|Text (*.txt)|*.txt|Rich Text (*.rtf)|*.rtf"
CommonDialog1.FilterIndex = 1
CommonDialog1.Flags = cdlOFNFileMustExist + cdlOFNHideReadOnly
CommonDialog1.CancelError = True
On Error Resume Next
CommonDialog1.ShowOpen
If Err Then
MsgBox "Dialog Cancelled"
Exit Sub
End If
tFile = FreeFile
Open CommonDialog1.FileName For Input As tFile
Text4.Text = Input(LOF(tFile), tFile)
Close tFile
MsgBox "You selected " & CommonDialog1.FileName
Exit Sub
End Sub
This displays text saved to the hard drive into a text box with no problem.
I also have a Cmd Button that plays an .avi file with the following code using the MM API in a module.
Private Sub cmdVideo_Click()
On Error Resume Next
Dim returnstring As String
Dim FileName As String
Dim i As String
Dim CommandString As String
returnstring = Space(127)
'AVIfile to play
If txtunit = "1" And txtlesson = "1" Then
FileName = "Introduction.avi"
i = mciSendString("open " & Chr$(34) & FileName & _
Chr$(34) & " type avivideo alias intro", returnstring, _
127, 0)
i = mciSendString("set video time format ms", _
returnstring, 127, 0)
i = mciSendString("play intro from 0", returnstring, _
127, 0)
i = mciSendString("play intro", 0&, 0, 0)
End If
(Repeted for additional videos)
There is also a cmdClose to close the video.
The problem is, after adding the Menu control the videos will no longer play with the cmdVideo Button. I have several other cmd Buttons that still function correctly, only the cmdVideo & cmdClose quit working. Any ideas what the problem is?
-
Try changing the FileName variable in the cmdVideo_Click() event to something else. I think it might be conflicting with the FileName property of the CommonDialog control... but perhaps not.
-
Thanks, Dreamlax but no that did not solve the problem.
-
Anyone else have an idea?
-
try setting a breakpoint at the start of the 2 events and step through when you hit the button..