Reply

Join Date: Aug 2009
Posts: 30
Reputation: drabsch is an unknown quantity at this point 
Solved Threads: 0
drabsch drabsch is offline Offline
Light Poster

Open file VB6

 
0
  #1
14 Days Ago
I am using a MDI Form and several documents can be opened using
"CommonDialog1.ShowOpen"

If i open a file then go back to open another file but click cancel or the "x" then it will open the last file.

so i need to know how to clear the "#1"

my code it:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. FileName = ""
  2. Data = ""
  3. MDIForm1.CommonDialog1.Filter = "All Files(*.*)|*.*|Text Files(*.txt)|*.txt|Web Files(*.html;*.htm;*.shtml;*.shtm;*.xhtml;*.php;*.php3;*.phtml;*.css;*.js;)|*.html;*.htm;*.shtml;*.shtm;*.xhtml;*.php;*.php3;*.phtml;*.css;*.js;|Batch Files(*.bat;*.cmd;*.nt;)|*.bat;*.cmd;*.nt;|VB Files(*.vb;*.vbs;*.frm;*.vbp;)|*.vb;*.vbs;*.frm;*.vbp;"
  4. On Error GoTo error
  5. MDIForm1.CommonDialog1.ShowOpen
  6. Me.Caption = MDIForm1.CommonDialog1.FileTitle
  7. FileName = MDIForm1.CommonDialog1.FileName
  8. Open FileName For Input As #1
  9.  
  10. Do Until EOF(1)
  11.  
  12. Input #1, Data
  13. Me.Text1.Text = Me.Text1.Text + Data + vbCrLf
  14. EOF (1)
  15. Loop
  16. Close #1
  17. FileName = ""
  18. Data = ""
  19. GoTo endload

Any ideas

I have cleared the "FileName" and "Data" but it still does it so i need to find a way to stop it.
Last edited by drabsch; 14 Days Ago at 1:25 am.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz
 
0
  #2
13 Days Ago
#1 refers to the file and the Close event will close the file.
If ALL my answers are wrong, only then will I read the question
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 800
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 146
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark
 
1
  #3
13 Days Ago
two different ways are shown in the following...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Option Explicit
  2.  
  3. Private Sub Command1_Click()
  4. OpenShowFile
  5. End Sub
  6.  
  7. Private Sub OpenShowFile()
  8.  
  9. On Error GoTo OpenShowFileError
  10.  
  11. Dim FName As String, FNumb As Integer
  12. Dim FileContents As String
  13.  
  14. CD.CancelError = True
  15. CD.Filter = "Text Files *.txt|*.txt"
  16. CD.FileName = vbNullString
  17. CD.ShowOpen
  18.  
  19. If CD.FileName = vbNullString Then Exit Sub
  20.  
  21. FName = CD.FileName
  22. FNumb = FreeFile
  23.  
  24. Open FName For Input As #FNumb
  25. FileContents = Input(FileLen(FName), #FNumb)
  26. Close #FNumb
  27.  
  28. Text1.Text = FileContents
  29.  
  30. Exit Sub
  31. OpenShowFileError:
  32.  
  33. If Err.Number = 32755 Then Exit Sub 'user pressed cancel
  34.  
  35. End Sub



Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC