Can't set the .Tag for a form (VB4) - Testform.zip (0/1) 
Author Message
 Can't set the .Tag for a form (VB4) - Testform.zip (0/1)

Can anyone explain this...

Attached you should find testform.zip.  This is a simple test.vbp:
frmTest has two buttons (exit, getfile).  Inside the getfile_click is
the following code:

   Private Sub Command2_Click()
      frmGetFile.Tag = "d:\temp\"
      MsgBox "Before GetFile: " & Chr(13) & Chr(10) & frmGetFile.Tag
      frmGetFile.Show 1
      MsgBox frmGetFile.Tag
   End Sub

Inside frmGetFile form_load is:
   Private Sub Form_Load()
      'update the directory lblDirName label with the
      'path value of the directory list box
      MsgBox "Inside GetFile: " & Chr(13) & Chr(10) & Me.Tag
      If Me.Tag = "" Then
         drvDrive.Drive = App.Path
         dirDirectory.Path = App.Path
      Else
         drvDrive.Drive = Me.Tag
         dirDirectory.Path = Me.Tag
      End If
      lblDirName.Caption = dirDirectory.Path
   End Sub

Now here is the problem.  When I click on GetFile (ie.
cammand2_click), I see the msgbox listed inside the frmGetFile
form_load event, and then the msgbox in the command2_click event.  Why
is this?  Secondly, when it shows the msgbox from inside frmGetFile
form_load, it shows Me.Tag is "".  Why can I set the Tag inside the
form, but not before calling the form?

I want to use frmGetFile as my default open file form for a couple of
small apps I'm working with.  It is my understanding that I can't use
the commondialog FileOpen or FileSave with VB4 16bit is this correct?
Or am I just beating myself over the head for no reason?

All help appreciated!

Mark



Sun, 23 May 1999 03:00:00 GMT  
 Can't set the .Tag for a form (VB4) - Testform.zip (0/1)

I think that there are some design issues here that you need to
address. Essentially you are trying to assign a property to a form
that is not loaded and then load the form.

At first look, it would seem that you want to get the directory
manipulation code out of the fom load event altogether.

Why not load the form from your first procedure and then have code in
the first procedure that sets the path to whatever you like and then
yields control to the form ?

I hope this is clear

Quote:

>Can anyone explain this...
>Attached you should find testform.zip.  This is a simple test.vbp:
>frmTest has two buttons (exit, getfile).  Inside the getfile_click is
>the following code:
>   Private Sub Command2_Click()
>      frmGetFile.Tag = "d:\temp\"
>      MsgBox "Before GetFile: " & Chr(13) & Chr(10) & frmGetFile.Tag
>      frmGetFile.Show 1
>      MsgBox frmGetFile.Tag
>   End Sub
>Inside frmGetFile form_load is:
>   Private Sub Form_Load()
>      'update the directory lblDirName label with the
>      'path value of the directory list box
>      MsgBox "Inside GetFile: " & Chr(13) & Chr(10) & Me.Tag
>      If Me.Tag = "" Then
>         drvDrive.Drive = App.Path
>         dirDirectory.Path = App.Path
>      Else
>         drvDrive.Drive = Me.Tag
>         dirDirectory.Path = Me.Tag
>      End If
>      lblDirName.Caption = dirDirectory.Path
>   End Sub
>Now here is the problem.  When I click on GetFile (ie.
>cammand2_click), I see the msgbox listed inside the frmGetFile
>form_load event, and then the msgbox in the command2_click event.  Why
>is this?  Secondly, when it shows the msgbox from inside frmGetFile
>form_load, it shows Me.Tag is "".  Why can I set the Tag inside the
>form, but not before calling the form?
>I want to use frmGetFile as my default open file form for a couple of
>small apps I'm working with.  It is my understanding that I can't use
>the commondialog FileOpen or FileSave with VB4 16bit is this correct?
>Or am I just beating myself over the head for no reason?
>All help appreciated!
>Mark

A mind which has been expanded by a new idea,
never returns to it's original dimensions.


Sun, 23 May 1999 03:00:00 GMT  
 Can't set the .Tag for a form (VB4) - Testform.zip (0/1)

Quote:

> Can anyone explain this...

> [snip]

> Now here is the problem.  When I click on GetFile (ie.
> cammand2_click), I see the msgbox listed inside the frmGetFile
> form_load event, and then the msgbox in the command2_click event.  Why
> is this?  Secondly, when it shows the msgbox from inside frmGetFile
> form_load, it shows Me.Tag is "".  Why can I set the Tag inside the
> form, but not before calling the form?

When you set frmGetFile, VB has to load that form before it can set the property.
So VB does its thing and fires off the load event of frmGetFile.
All of that code runs and you get you message box in fmrGetFile, but the tag
has not yet been set so it is empty.  When frmGetFile_load completes, control is
retruned back to the click event where the tag is being set and you are
getting your second message box.

What you might want to do is move your code to the activate event instead
of the load event.  That way, the form will load, the tag will be set and
then your code will actually run when you do the modal show.

JJ Brychell          - My opinions are my own and not necessarily



Sun, 23 May 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Can't set the .Tag for a form (VB4) - Testform.zip (1/1)

2. 'Canned' data in VB program

3. can I set ComboBox item's tag

4. Crystal reports v8.5 doesn't parse entire HTML tag set, specifically tables

5. Setting tag-property and save form

6. How do I create a canned form?

7. Can't set form's icon

8. a set of vb4.0 ?'s

9. MP3 'ID3 Tag' Issue

10. Force a tag to '1'

11. VB4 - can't set print font or size

12. a set of vb4.0 ?'s (simple)

 

 
Powered by phpBB® Forum Software