Home All Groups Group Topic Archive Search About
Author
11 Jun 2009 5:06 PM
Melvin
I have continuing difficulty understand just how and when a form is
displayed. The specifics this time is as follows:

I have two forms. Form1 and Form2

Form1 is displayed  and  at some point, based on user input ,I want to hide
Form 1, switch to Form 2, display it and run the only procedure (GetPrices)
contained in it then unload it and return to Form 1 and make it visible and
continue processing.

There is no user input on Form2, only a label with fixed data.

I have tried all kind of  combinations involving using Form2.show 0,
Form2.show 1,  doing a "Call Form2.GetPrices", ZOrder, Refresh, etc.  but
cannot find a means of accomplishing what I want.

Any assistance would be appreciated.

Mel

Author
11 Jun 2009 6:15 PM
Larry Serflaten
Show quote Hide quote
"Melvin" <marvw***@columbus.rr.com> wrote
> I have continuing difficulty understand just how and when a form is
> displayed. The specifics this time is as follows:
>
> I have two forms. Form1 and Form2
>
> Form1 is displayed  and  at some point, based on user input ,I want to hide
> Form 1, switch to Form 2, display it and run the only procedure (GetPrices)
> contained in it then unload it and return to Form 1 and make it visible and
> continue processing.
>
> There is no user input on Form2, only a label with fixed data.
>
> I have tried all kind of  combinations involving using Form2.show 0,
> Form2.show 1,  doing a "Call Form2.GetPrices", ZOrder, Refresh, etc.  but
> cannot find a means of accomplishing what I want.
>
> Any assistance would be appreciated.


It seems pretty straight forward to me....

Try this, start a new project and add Form2.  Add a button to Form1 and
paste the following code in their respective code modules.
(There are other ways to do it, this is just one way...)

LFS


' [Form1 code]
Private Sub Command1_Click()
  Me.Hide
  Form2.GetPrices
  Me.Show
End Sub


' [Form2 code]
Public Sub GetPrices()
  Me.Caption = "Use X to close the form"
  Me.Show vbModal
End Sub
Are all your drivers up to date? click for free checkup

Author
11 Jun 2009 7:44 PM
Melvin
Show quote Hide quote
"Larry Serflaten" <serfla***@usinternet.com> wrote in message
news:OZQKMBs6JHA.5932@TK2MSFTNGP03.phx.gbl...
>
> "Melvin" <marvw***@columbus.rr.com> wrote
>> I have continuing difficulty understand just how and when a form is
>> displayed. The specifics this time is as follows:
>>
>> I have two forms. Form1 and Form2
>>
>> Form1 is displayed  and  at some point, based on user input ,I want to
>> hide
>> Form 1, switch to Form 2, display it and run the only procedure
>> (GetPrices)
>> contained in it then unload it and return to Form 1 and make it visible
>> and
>> continue processing.
>>
>> There is no user input on Form2, only a label with fixed data.
>>
>> I have tried all kind of  combinations involving using Form2.show 0,
>> Form2.show 1,  doing a "Call Form2.GetPrices", ZOrder, Refresh, etc.  but
>> cannot find a means of accomplishing what I want.
>>
>> Any assistance would be appreciated.
>
>
> It seems pretty straight forward to me....
>
> Try this, start a new project and add Form2.  Add a button to Form1 and
> paste the following code in their respective code modules.
> (There are other ways to do it, this is just one way...)
>
> LFS
>
>
> ' [Form1 code]
> Private Sub Command1_Click()
>  Me.Hide
>  Form2.GetPrices
>  Me.Show
> End Sub
>
>
> ' [Form2 code]
> Public Sub GetPrices()
>  Me.Caption = "Use X to close the form"
>  Me.Show vbModal
> End Sub
>
>

Larry, thank you for  your response.

I should have included the fact that Form1 is actually displayed from  a
FormA using Form1.Show. So that apparently causes a problem when I get to
the Me.show in Form1 in your suggestion.  In addition, I really wanted to
avoid have any user interaction in Form2.

Essentially what I am trying to do is to get stock prices from the  internet
using a routine I found.
I would have liked to have this routine in a procedure  in a base module but
it seems to requires  the  inclusion of  the Microsoft Internet Transfer
Control 6.0 on the form that executes the lookup to be able to work   That
is the purpose of  Form2.

I am far from a professional programmer so  I may be grossly missing
something very obviously that would make easier.  Thank God for this forum.

Mel
Author
11 Jun 2009 11:48 PM
Larry Serflaten
"Melvin" <marvw***@columbus.rr.com> wrote

> Larry, thank you for  your response.
>
> I should have included the fact that Form1 is actually displayed from  a
> FormA using Form1.Show. So that apparently causes a problem when I get to
> the Me.show in Form1 in your suggestion.  In addition, I really wanted to
> avoid have any user interaction in Form2.

Yep that would be a problem.  As far as user interaction, had I unloaded the
form in GetPrices, the whole thing would have happend so fast as to only
be a flash and you'd be back at Form1.

Why do you need to show Form2?  You can use it without making it visible.

LFS
Author
12 Jun 2009 12:03 AM
Webbiz
On Thu, 11 Jun 2009 15:44:56 -0400, "Melvin"
<marvw***@columbus.rr.com> wrote:

Show quoteHide quote
>"Larry Serflaten" <serfla***@usinternet.com> wrote in message
>news:OZQKMBs6JHA.5932@TK2MSFTNGP03.phx.gbl...
>>
>> "Melvin" <marvw***@columbus.rr.com> wrote
>>> I have continuing difficulty understand just how and when a form is
>>> displayed. The specifics this time is as follows:
>>>
>>> I have two forms. Form1 and Form2
>>>
>>> Form1 is displayed  and  at some point, based on user input ,I want to
>>> hide
>>> Form 1, switch to Form 2, display it and run the only procedure
>>> (GetPrices)
>>> contained in it then unload it and return to Form 1 and make it visible
>>> and
>>> continue processing.
>>>
>>> There is no user input on Form2, only a label with fixed data.
>>>
>>> I have tried all kind of  combinations involving using Form2.show 0,
>>> Form2.show 1,  doing a "Call Form2.GetPrices", ZOrder, Refresh, etc.  but
>>> cannot find a means of accomplishing what I want.
>>>
>>> Any assistance would be appreciated.
>>
>>
>> It seems pretty straight forward to me....
>>
>> Try this, start a new project and add Form2.  Add a button to Form1 and
>> paste the following code in their respective code modules.
>> (There are other ways to do it, this is just one way...)
>>
>> LFS
>>
>>
>> ' [Form1 code]
>> Private Sub Command1_Click()
>>  Me.Hide
>>  Form2.GetPrices
>>  Me.Show
>> End Sub
>>
>>
>> ' [Form2 code]
>> Public Sub GetPrices()
>>  Me.Caption = "Use X to close the form"
>>  Me.Show vbModal
>> End Sub
>>
>>
>
>Larry, thank you for  your response.
>
>I should have included the fact that Form1 is actually displayed from  a
>FormA using Form1.Show. So that apparently causes a problem when I get to
>the Me.show in Form1 in your suggestion.  In addition, I really wanted to
>avoid have any user interaction in Form2.
>
>Essentially what I am trying to do is to get stock prices from the  internet
>using a routine I found.
>I would have liked to have this routine in a procedure  in a base module but
>it seems to requires  the  inclusion of  the Microsoft Internet Transfer
>Control 6.0 on the form that executes the lookup to be able to work   That
>is the purpose of  Form2.
>
>I am far from a professional programmer so  I may be grossly missing
>something very obviously that would make easier.  Thank God for this forum.
>
>Mel
>
>


I'm curious Mel.

Are you looking to use Form2 for any purpose other than to just
'contain' the control to get access to its methods?

Webbiz
Author
12 Jun 2009 5:20 PM
Melvin
Show quote Hide quote
"Webbiz" <nospam@forme.thanks.com> wrote in message
news:3j6335p32ihijbh9inmq9aik7ta9luadik@4ax.com...
> On Thu, 11 Jun 2009 15:44:56 -0400, "Melvin"
> <marvw***@columbus.rr.com> wrote:
>
>>"Larry Serflaten" <serfla***@usinternet.com> wrote in message
>>news:OZQKMBs6JHA.5932@TK2MSFTNGP03.phx.gbl...
>>>
>>> "Melvin" <marvw***@columbus.rr.com> wrote
>>>> I have continuing difficulty understand just how and when a form is
>>>> displayed. The specifics this time is as follows:
>>>>
>>>> I have two forms. Form1 and Form2
>>>>
>>>> Form1 is displayed  and  at some point, based on user input ,I want to
>>>> hide
>>>> Form 1, switch to Form 2, display it and run the only procedure
>>>> (GetPrices)
>>>> contained in it then unload it and return to Form 1 and make it visible
>>>> and
>>>> continue processing.
>>>>
>>>> There is no user input on Form2, only a label with fixed data.
>>>>
>>>> I have tried all kind of  combinations involving using Form2.show 0,
>>>> Form2.show 1,  doing a "Call Form2.GetPrices", ZOrder, Refresh, etc.
>>>> but
>>>> cannot find a means of accomplishing what I want.
>>>>
>>>> Any assistance would be appreciated.
>>>
>>>
>>> It seems pretty straight forward to me....
>>>
>>> Try this, start a new project and add Form2.  Add a button to Form1 and
>>> paste the following code in their respective code modules.
>>> (There are other ways to do it, this is just one way...)
>>>
>>> LFS
>>>
>>>
>>> ' [Form1 code]
>>> Private Sub Command1_Click()
>>>  Me.Hide
>>>  Form2.GetPrices
>>>  Me.Show
>>> End Sub
>>>
>>>
>>> ' [Form2 code]
>>> Public Sub GetPrices()
>>>  Me.Caption = "Use X to close the form"
>>>  Me.Show vbModal
>>> End Sub
>>>
>>>
>>
>>Larry, thank you for  your response.
>>
>>I should have included the fact that Form1 is actually displayed from  a
>>FormA using Form1.Show. So that apparently causes a problem when I get to
>>the Me.show in Form1 in your suggestion.  In addition, I really wanted to
>>avoid have any user interaction in Form2.
>>
>>Essentially what I am trying to do is to get stock prices from the
>>internet
>>using a routine I found.
>>I would have liked to have this routine in a procedure  in a base module
>>but
>>it seems to requires  the  inclusion of  the Microsoft Internet Transfer
>>Control 6.0 on the form that executes the lookup to be able to work   That
>>is the purpose of  Form2.
>>
>>I am far from a professional programmer so  I may be grossly missing
>>something very obviously that would make easier.  Thank God for this
>>forum.
>>
>>Mel
>>
>>
>
>
> I'm curious Mel.
>
> Are you looking to use Form2 for any purpose other than to just
> 'contain' the control to get access to its methods?
>
> Webbiz

No, I  just have not been able to get the web lookup to run  without using a
form to contain the control.

Mel
Author
12 Jun 2009 10:16 PM
Webbiz
On Fri, 12 Jun 2009 13:20:17 -0400, "Melvin"
<marvw***@columbus.rr.com> wrote:


>>
>> I'm curious Mel.
>>
>> Are you looking to use Form2 for any purpose other than to just
>> 'contain' the control to get access to its methods?
>>
>> Webbiz
>
>No, I  just have not been able to get the web lookup to run  without using a
>form to contain the control.
>
>Mel


That's what I was asking. If you need a form to contain your control
so that you can use run (access) its methods and don't need to
'display' the control itself.

I would think that if you simply want to run methods from the control
and it does not need to be a visible control (I'm not familiar with
the control in question, so if it must be visible then scratch my
question), you could just place it on your main form out of the way
and then have access to the methods without having to open another
form.

Webbiz
Author
12 Jun 2009 11:43 AM
Nobody
"Melvin" <marvw***@columbus.rr.com> wrote in message
news:e1Z6Nzs6JHA.4116@TK2MSFTNGP04.phx.gbl...
> I would have liked to have this routine in a procedure  in a base module
> but it seems to requires  the  inclusion of  the Microsoft Internet
> Transfer Control 6.0 on the form that executes the lookup to be able to
> work   That is the purpose of  Form2.

The Internet Transfer Control is buggy and it will bite you sooner or later.
Use the following VB6 sample instead, which uses URLDownloadToFile() API
function, so you don't need a form. You can put the code in a standard
Module, make DownloadFile() Public, and use it anywhere from your project.

This function is based on IE. It normally doesn't download the file if it's
already present in the browser cache, however, the sample shows how to make
sure that the file is always downloaded from the web.

URLDownloadToFile: Fast, Simple and Transparent File Downloads Bypassing the
IE Cache
http://www.vbnet.mvps.org/code/internet/urldownloadtofilenocache.htm
Author
12 Jun 2009 5:46 PM
Nobody
Show quote Hide quote
"Nobody" <nob***@nobody.com> wrote in message
news:emo2GR16JHA.1196@TK2MSFTNGP03.phx.gbl...
> "Melvin" <marvw***@columbus.rr.com> wrote in message
> news:e1Z6Nzs6JHA.4116@TK2MSFTNGP04.phx.gbl...
>> I would have liked to have this routine in a procedure  in a base module
>> but it seems to requires  the  inclusion of  the Microsoft Internet
>> Transfer Control 6.0 on the form that executes the lookup to be able to
>> work   That is the purpose of  Form2.
>
> The Internet Transfer Control is buggy and it will bite you sooner or
> later. Use the following VB6 sample instead, which uses
> URLDownloadToFile() API function, so you don't need a form. You can put
> the code in a standard Module, make DownloadFile() Public, and use it
> anywhere from your project.
>
> This function is based on IE. It normally doesn't download the file if
> it's already present in the browser cache, however, the sample shows how
> to make sure that the file is always downloaded from the web.
>
> URLDownloadToFile: Fast, Simple and Transparent File Downloads Bypassing
> the IE Cache
> http://www.vbnet.mvps.org/code/internet/urldownloadtofilenocache.htm

Could some quote the post above so Melvin can see it. It seems that it's not
visible at his newsserver.
Author
12 Jun 2009 6:10 PM
Melvin
Show quote Hide quote
"Nobody" <nob***@nobody.com> wrote in message
news:%23YIzHX46JHA.4376@TK2MSFTNGP06.phx.gbl...
> "Nobody" <nob***@nobody.com> wrote in message
> news:emo2GR16JHA.1196@TK2MSFTNGP03.phx.gbl...
>> "Melvin" <marvw***@columbus.rr.com> wrote in message
>> news:e1Z6Nzs6JHA.4116@TK2MSFTNGP04.phx.gbl...
>>> I would have liked to have this routine in a procedure  in a base module
>>> but it seems to requires  the  inclusion of  the Microsoft Internet
>>> Transfer Control 6.0 on the form that executes the lookup to be able to
>>> work   That is the purpose of  Form2.
>>
>> The Internet Transfer Control is buggy and it will bite you sooner or
>> later. Use the following VB6 sample instead, which uses
>> URLDownloadToFile() API function, so you don't need a form. You can put
>> the code in a standard Module, make DownloadFile() Public, and use it
>> anywhere from your project.
>>
>> This function is based on IE. It normally doesn't download the file if
>> it's already present in the browser cache, however, the sample shows how
>> to make sure that the file is always downloaded from the web.
>>
>> URLDownloadToFile: Fast, Simple and Transparent File Downloads Bypassing
>> the IE Cache
>> http://www.vbnet.mvps.org/code/internet/urldownloadtofilenocache.htm
>
> Could some quote the post above so Melvin can see it. It seems that it's
> not visible at his newsserver.
>
>
>

I can see it.  I downloaded the source code and am trying to see if I can
convert it to a procedure that would run in a module to avoid using a form
at all.

Thanks for the tip.

Mel
Author
11 Jun 2009 6:22 PM
dpb
Melvin wrote:
> I have continuing difficulty understand just how and when a form is
> displayed. The specifics this time is as follows:
>
> I have two forms. Form1 and Form2
>
> Form1 is displayed  and  at some point, based on user input ,I want to
> hide Form 1, switch to Form 2, display it and run the only procedure
> (GetPrices) contained in it then unload it and return to Form 1 and make
> it visible and continue processing.
>
> There is no user input on Form2, only a label with fixed data.
....
Not sure _why_ you would choose to do it this way, but...

The one thing you'll have to be sure to do is to have the function that
calls the second form redisplay the form that _does_ have some user
interaction on it or you'll be stuck showing that label until kill the app.

Add a command button to Form1 and a Label to Form2 in a project and
paste into their respective forms..

Private Sub Command1_Click()
   Dim PauseTime, Start
   Form1.Hide
   Form2.Show
   Form2.Form2Sub
   PauseTime = 5 ' Set duration.
   Start = Timer ' Set start time.
   Do While Timer < Start + PauseTime
     DoEvents
   Loop
   Form2.Hide
   Form1.Show
End Sub

Sub Form2Sub()
   Form2.Label1 = "New Text From Form2"
End Sub

--
Author
11 Jun 2009 7:47 PM
Melvin
Show quote Hide quote
"dpb" <n***@non.net> wrote in message news:h0ri66$qii$1@aioe.org...
> Melvin wrote:
>> I have continuing difficulty understand just how and when a form is
>> displayed. The specifics this time is as follows:
>>
>> I have two forms. Form1 and Form2
>>
>> Form1 is displayed  and  at some point, based on user input ,I want to
>> hide Form 1, switch to Form 2, display it and run the only procedure
>> (GetPrices) contained in it then unload it and return to Form 1 and make
>> it visible and continue processing.
>>
>> There is no user input on Form2, only a label with fixed data.
> ...
> Not sure _why_ you would choose to do it this way, but...
>
> The one thing you'll have to be sure to do is to have the function that
> calls the second form redisplay the form that _does_ have some user
> interaction on it or you'll be stuck showing that label until kill the
> app.
>
> Add a command button to Form1 and a Label to Form2 in a project and paste
> into their respective forms..
>
> Private Sub Command1_Click()
>   Dim PauseTime, Start
>   Form1.Hide
>   Form2.Show
>   Form2.Form2Sub
>   PauseTime = 5 ' Set duration.
>   Start = Timer ' Set start time.
>   Do While Timer < Start + PauseTime
>     DoEvents
>   Loop
>   Form2.Hide
>   Form1.Show
> End Sub
>
> Sub Form2Sub()
>   Form2.Label1 = "New Text From Form2"
> End Sub
>
> --

Please see my reply to Larry above. Maybe this would help you understand why
I believed this way the only way to do what I am attempting to do.

Mel

Bookmark and Share