• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 882
  • Last Modified:

CommonDialog Control in VB5

Im converting a VB4 program into VB5 but the commonDialog Control (using file open) in my program is no longer supported in VB5. What code should I use in replace of it?

CommonDialog1.Flags = cdlOFNFileMustExist& cdlOFNPathMustExist &cdOFNLongNames & cdlOFNHideReadOnly

CommonDialog1.InitDir = "C:\Program Files"
   If CommonDialog1.filename <> "" Then
      Me.Text1(Index).Text = CommonDialog1.filename
   end if
  • 2
1 Solution
When setting the flags use 'Or' instead of '&'. Other than that it's fine.

CommonDialog1.Flags = cdlOFNFileMustExist Or _
cdlOFNPathMustExist Or cdlOFNLongNames Or cdlOFNHideReadOnly

LeeGarAuthor Commented:
I guess it isn't the code, but I had to delete the old commonDialog object off my form(it was registering it as a commonDialogPictureBox!) and go to Project/Components and select CommonDialog controls 6 and reinsert the control back on the form. But for some reason when I try to work on the program on another computer that didn't have VB4 on it, It tells me I dont have licence approval for some ocx controls ????who knows!
To fix this remove the control from your projects form and then find out where the ms commoncontrol 5.0 is pointing to. That file should be in the win system dir as mscomdlg32.ocx.
if not, move the file its pointing to (so it clears itself) & then browse to the ocx file mentioned to re-establish the commonDialog control on your form. Then you can add it again to your form & save!
LeeGarAuthor Commented:
That works, your right on VB doesn't let you change registered controls, only if it can't find it anymore will it clear!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now