Wrox Programmer Forums
|
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
 
Old November 17th, 2006, 06:09 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default 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.
 
Old November 17th, 2006, 07:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

did you open the file? I do not see a line like

Open "myTESTFILE" For Output As #1
 
Old November 18th, 2006, 08:02 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

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!
 
Old November 20th, 2006, 02:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 22nd, 2006, 02:02 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

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!
 
Old November 22nd, 2006, 05:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old November 22nd, 2006, 05:29 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

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!
 
Old November 27th, 2006, 02:07 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable Property kekec3778 Beginning VB 6 2 January 8th, 2008 06:32 AM
Parameterized Property surendraparashar C# 2005 4 October 17th, 2007 11:33 PM
property umeshtheone Beginning VB 6 2 May 18th, 2007 12:37 AM
C# property with parameters yazheirx C# 0 September 7th, 2006 02:48 PM
TopMost Property shadowpug VB.NET 2002/2003 Basics 0 September 27th, 2004 09:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.