 |
| Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 17th, 2006, 06:09 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
CommonDialog Save Property
Hi Everyone new dilema,
Now apperently theres a "Bad Filename or Number" when I test run my app and the line in bold is highlighted yellow
Private Sub cmdSave_Click()
If Check3.Value = 1 And Check4.Value = 0 Then
CommonDialog1.DialogTitle = "Save Panel"
CommonDialog1.Filter = "Textpad (*.txt)|*.txt"
CommonDialog1.ShowSave
Print #1, lstLeft.Text ElseIf Check4.Value = 1 And Check3.Value = 0 Then
CommonDialog1.DialogTitle = "Save " & Check3.Caption & " Panel"
CommonDialog1.Filter = "Textpad (*.txt)|*.txt"
CommonDialog1.ShowSave
Print #1, lstRight.Text Else
MsgBox "Try selecting one or the other"
End If
End Sub
Need some help if anyone can!
Thanks alot
------------------------------------------------
Apocolypse2005
Always ready and waiting to help!
__________________
Apocolypse2005, I'm a programmer - of sorts.
|
|

November 17th, 2006, 07:40 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
did you open the file? I do not see a line like
Open "myTESTFILE" For Output As #1
|
|

November 18th, 2006, 08:02 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
Right, i've sorted that out and have now go this error on this line
"Variable Not Defined"
If Check3.Value = 1 And Check4.Value = 0 Then
CommonDialog1.DialogTitle = "Save Panel"
CommonDialog1.Filter = "Textpad (*.txt)|*.txt"
CommonDialog1.ShowSave
CommonDialog1.FileName = "FSave" 'the file the user selected is "FSave"
Open FSave For Binary Shared As #1: Close #1: Kill FSave 'open. closes, and deletes the file
Open FSave For Output Shared As #1 'opens file for output
Print #1, lstLeft.Text
Close #1
I think I know why! its because its not executing the red line then waiting for the variable to be defined so it can continue! But I could most proberly be wrong!
Thanks for the last post, it was extremely useful!
------------------------------------------------
Apocolypse2005
Always ready and waiting to help!
|
|

November 20th, 2006, 02:04 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
in the line:
Open FSave For Binary Shared As #1
the variable FSave is not defined
Maybe what you wanted to do is:
dim fsave as string
fsave = commondialog1.filename
open fsave .... etc etc
the line:
CommonDialog1.FileName = "FSave"
does not make any sense. you want the file selected by the user, not to hardcode a name
|
|

November 22nd, 2006, 02:02 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
Even with that as a variable, it doesnt work!
It stumped me, i have tried everyway to change it and tht must of been one of them, but it still doesn't work!
|
|

November 22nd, 2006, 05:25 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
well, what do you mean with "it still doesn't work"? can you give us some little clues? :)
post you code and we'll take a look
|
|

November 22nd, 2006, 05:29 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
Here it is:
Private Sub cmdSave_Click()
If Check3.Value = 1 And Check4.Value = 0 Then
CommonDialog1.DialogTitle = "Save Panel"
CommonDialog1.Filter = "Textpad (*.txt)|*.txt"
CommonDialog1.ShowSave
CommonDialog1.FileName = FSave 'the file the user selected is "FSave"
Open FSave For Binary Shared As #1: Close #1: Kill FSave 'open. closes, and deletes the file
Open FSave For Output Shared As #1 'opens file for output
Print #1, lstLeft.Text
Close #1
ElseIf Check4.Value = 1 And Check3.Value = 0 Then
CommonDialog1.DialogTitle = "Save " & Check3.Caption & " Panel"
CommonDialog1.Filter = "Textpad (*.txt)|*.txt"
CommonDialog1.ShowSave
CommonDialog1.FileName = FSave 'the file the user selected is "FSave"
Open FSave For Binary Shared As #1: Close #1: Kill FSave 'open. closes, and deletes the file
Open FSave For Output Shared As #1 'opens file for output
Print #1, lstLeft.Text
Close #1
Else
MsgBox "Try selecting one or the other"
End If
End Sub
------------------------------------------------
Apocolypse2005
Always ready and waiting to help!
|
|

November 27th, 2006, 02:07 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
again you don't say what is wrong with it...
I already told you what is wrong with the FSave variable, don't do
commondialo1.filename = fsave
but
fsave = commodialog1.filename
|
|
 |