Results 1 to 10 of 10

Thread: variable not defined

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2018
    Posts
    21

    variable not defined

    I am a novice user and vision impaired. my program required me to fix some items in a list which I was able to do successfully. However, when I clicked on make exe I get variable not defined.

    CommonDialog1 is highlighted second line after the equals sign
    here's the code sample:


    Private Sub mnuHelpContents_Click()
    CommonDialog1.HelpFile = CommonDialog1.HelpFile
    CommonDialog1.HelpCommand = cdlHelpContents
    CommonDialog1.ShowHelp
    End Sub

    my program has a help button in the menu but doesn't work as windows stopped winhelp from working in windows 10

    any ideas? Thanks

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: variable not defined

    1) you've posted in the Codebank which is for sharing code snips, not getting help - I'll ask the mods to move the thread to a more appropriate location.
    2) How does this line even make sense:
    Code:
    CommonDialog1.HelpFile = CommonDialog1.HelpFile
    You set a equal to a ... there's no need for that... it is what it is, and doesn't need to be set back to itself. What it SHOULD be set to is the path where the help file is located.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2018
    Posts
    21

    Re: variable not defined

    thank you, I will give it a try. I have 2 help files one is winhelp which does not work. Microsoft dropped it. Have an HTML help FILE
    maybe this causing a similiar problem trying to get it to work also. I will use your suggestion

  4. #4
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: variable not defined

    Not having used the Help system in a very long time, I had to consult the VB6 manual. Searching the disk for ".hlp" files, I found a few in the "syswow64" directory and substituted in this code from the manual.
    Code:
    Private Sub Command1_Click()
       CommonDialog1.CancelError = True
       On Error GoTo ErrHandler
       CommonDialog1.HelpCommand = cdlHelpForceFile
       CommonDialog1.HelpFile = "C:\Windows\syswow64\NTSVC.HLP"
       CommonDialog1.ShowHelp
       Exit Sub
    ErrHandler:
       Exit Sub
    End Sub
    It works like a charm. Normally, you can find these types of errors before compiling by using "Option Explicit" in the declaration section. This is always a must for me.

    J.A. Coutts

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: variable not defined

    Based on the error I would say that this variable
    Code:
    cdlHelpContents
    Is not defined and has no value.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jul 2018
    Posts
    21

    Re: variable not defined

    thank you will check it out

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2018
    Posts
    21

    Re: variable not defined

    thank you I will have to search for the undefined variables

  8. #8
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: variable not defined

    Two suggestions that everyone should follow -

    To explicitly declare variables
    From the Tools menu, choose Options, click the Editor tab and check the Require Variable Declaration option. This automatically inserts the Option Explicit statement in any new modules, but not in modules already created; therefore, you must manually add Option Explicit to any existing modules within a project.

    Don't wait until you try to make an EXE to find outstanding problems.
    Every time I run my program in the IDE, I use the key combination -
    Hold down the Alt key, and then type fsrf
    That will save the file you just edited, and run the program with full compile

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: variable not defined

    Run with full compile is fine for small programs but not needed in most cases. I assume that most programmers test run their programs often so as to make sure things are working before they write to much code. In such cases the test run usually focuses on the new code just added/changed and most of the time the other code is untouched so compiling it over and over is a waste of time. On small programs this is not a big deal but larger ones it can be, Over the course of a programs life that little always run with full compile can add hours of the programmers time and often not catch anything that would not be caught during normal testing.

    I'm not sure where the ALT fsrf comes in? Ctrl+F5 is the hotkey to start with full compile and the IDE has an option to always save on run or to prompt for save on run which is the setting I use as I do not always want to save.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jul 2018
    Posts
    21

    Re: variable not defined

    thankyou to Bobbles and DataMiser for responding. my problem is when I make a change to the my program in need to post a new upgraded EXE. The EXE THEN HAS to be encrypted then put into install shield, then put on my website with notifications to users. history of the program is winhelp worked thru windows & no problem.
    then Microsoft decided to stop winhelp . . . when you click help in bar menu it sends you to Microsoft with a no longer supported message. Xo I bought a program reconfigured Help to HTML file put in supplied code to implement only to find that Microsoft views distributed HTML help as possible malware . . .and won't let it work so I package the HTML with the software and clients can open it on their computers.

    I commented out the help code and compiled the project and it worked initially 2018.

    Now I made a couple of changes to a list in the program and associated table for the list and get the commondialog1 error variable not defined???

    I need to figure out why this won't complile it works fine when I run the project in vb 6.
    how do I get to an EXE for update and distribution? Thanks for your comments

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width