-
Jul 9th, 2021, 09:07 AM
#1
Thread Starter
Junior Member
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
-
Jul 9th, 2021, 10:50 AM
#2
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
-
Jul 9th, 2021, 05:22 PM
#3
Thread Starter
Junior Member
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
-
Jul 9th, 2021, 05:56 PM
#4
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
-
Jul 9th, 2021, 07:20 PM
#5
Re: variable not defined
Based on the error I would say that this variable Is not defined and has no value.
-
Jul 10th, 2021, 08:41 AM
#6
Thread Starter
Junior Member
Re: variable not defined
thank you will check it out
-
Jul 10th, 2021, 08:58 AM
#7
Thread Starter
Junior Member
Re: variable not defined
thank you I will have to search for the undefined variables
-
Jul 10th, 2021, 09:50 PM
#8
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
-
Jul 10th, 2021, 10:34 PM
#9
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.
-
Jul 11th, 2021, 08:25 AM
#10
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|