/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
array of forms
Fra : Jan Raes


Dato : 03-08-01 11:41

Hello,

I am looking for a solution for this problem :
I have specified an array of forms. Each form contains an algoritm which
got to live his own life :
they got to run simultanuously and not sequentially. I didn't succeeded
until now. Help!

Example :
Create a Form "FrmCounter" with a textbox control "Text1"
and a Commandbutton control "Command1"
Use the following code :

Private Sub Command1_Click()
Dim A As Long
For A = 1 To 50000
Text1.Text = CStr(A)
Text1.Refresh
Next
End Sub

Create a module "Start" with the following sub

Public Sub main()
Dim Frm() As New FrmCounter
Dim C As Integer
ReDim Frm(5)
For C = 1 To NForms
Frm(C).Show
Next C
End Sub

Define Main() as the startup object.

When running there are 5 forms displayed on the screen.
When pressing the commandbutton on form 5 the counterloop on form 5
starts counting
While this form is busy counting, you can't start commandbutton on form
2 and that's just what I want to do. With other words :
How to share processor time between several open forms without the need
to create 2 seperate programs : a first, main program which calls (shell)
x-times a second, child application.

Thanks for your help
Regards
Jan




 
 
Per Madsen (04-08-2001)
Kommentar
Fra : Per Madsen


Dato : 04-08-01 20:13


"Jan Raes" <jan.raes@catech.be> wrote in message
news:9kdv33$2lc$1@news.planetinternet.be...
> Hello,
>
> I am looking for a solution for this problem :
> I have specified an array of forms. Each form contains an algoritm which
> got to live his own life :
> they got to run simultanuously and not sequentially. I didn't succeeded
> until now. Help!
>
> Example :
> Create a Form "FrmCounter" with a textbox control "Text1"
> and a Commandbutton control "Command1"
> Use the following code :
>
> Private Sub Command1_Click()
> Dim A As Long
> For A = 1 To 50000
> Text1.Text = CStr(A)
> Text1.Refresh
> Next
> End Sub
>
> Create a module "Start" with the following sub
>
> Public Sub main()
> Dim Frm() As New FrmCounter
> Dim C As Integer
> ReDim Frm(5)
> For C = 1 To NForms
> Frm(C).Show
> Next C
> End Sub
>
> Define Main() as the startup object.
>
> When running there are 5 forms displayed on the screen.
> When pressing the commandbutton on form 5 the counterloop on form 5
> starts counting
> While this form is busy counting, you can't start commandbutton on form
> 2 and that's just what I want to do. With other words :
> How to share processor time between several open forms without the need
> to create 2 seperate programs : a first, main program which calls (shell)
> x-times a second, child application.
>
> Thanks for your help
> Regards
> Jan
>
Hello Jan
Try to enter a DoEvents like

Private Sub Command1_Click()
Dim A As Long
For A = 1 To 50000
Text1.Text = CStr(A)
DoEvents 'DoEvents will execute all
events pending including
'command button on form 2
Text1.Refresh 'You may not need Text1.Refresh
now....
Next
End Sub




Jan Raes (06-08-2001)
Kommentar
Fra : Jan Raes


Dato : 06-08-01 09:49

Hello Per

Thanks for your reply
DoEvents doesn't really helps as it's still a sequential application
and not a multitasking one
Thanks any way
Jan

"Per Madsen" <per_madsen@pmlotto.dk> wrote in message
news:3b6c49de$0$31240$ba624c82@nntp01.dk.telia.net...
>
> "Jan Raes" <jan.raes@catech.be> wrote in message
> news:9kdv33$2lc$1@news.planetinternet.be...
> > Hello,
> >
> > I am looking for a solution for this problem :
> > I have specified an array of forms. Each form contains an algoritm which
> > got to live his own life :
> > they got to run simultanuously and not sequentially. I didn't succeeded
> > until now. Help!
> >
> > Example :
> > Create a Form "FrmCounter" with a textbox control "Text1"
> > and a Commandbutton control "Command1"
> > Use the following code :
> >
> > Private Sub Command1_Click()
> > Dim A As Long
> > For A = 1 To 50000
> > Text1.Text = CStr(A)
> > Text1.Refresh
> > Next
> > End Sub
> >
> > Create a module "Start" with the following sub
> >
> > Public Sub main()
> > Dim Frm() As New FrmCounter
> > Dim C As Integer
> > ReDim Frm(5)
> > For C = 1 To NForms
> > Frm(C).Show
> > Next C
> > End Sub
> >
> > Define Main() as the startup object.
> >
> > When running there are 5 forms displayed on the screen.
> > When pressing the commandbutton on form 5 the counterloop on form 5
> > starts counting
> > While this form is busy counting, you can't start commandbutton on form
> > 2 and that's just what I want to do. With other words :
> > How to share processor time between several open forms without the need
> > to create 2 seperate programs : a first, main program which calls
(shell)
> > x-times a second, child application.
> >
> > Thanks for your help
> > Regards
> > Jan
> >
> Hello Jan
> Try to enter a DoEvents like
>
> Private Sub Command1_Click()
> Dim A As Long
> For A = 1 To 50000
> Text1.Text = CStr(A)
> DoEvents 'DoEvents will execute all
> events pending including
> 'command button on form
2
> Text1.Refresh 'You may not need
Text1.Refresh
> now....
> Next
> End Sub
>
>
>



Per Madsen (06-08-2001)
Kommentar
Fra : Per Madsen


Dato : 06-08-01 18:30

Sorry Jan,

I was so sure that it would work, that
I had to try it. when I read your reply....
You are right of cource, however at least
any form was running - solely

Trying to preserve a little pride I rush
with another suggestion, that might help you
depending on the actual code you want to use.

Best regards

Per

Add a Timer, disabled and Interval 10 to your frmCount.

Module1:
____________________________________

Public Sub main()
Dim Frm() As New frmCounter
Dim C As Integer, NForms As Integer
NForms = 5
ReDim Frm(NForms)
For C = 1 To NForms
Frm(C).Show
Next C
End Sub
____________________________________

frmCounter:
____________________________________

Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
____________________________________

Private Sub Timer1_Timer()

Static A As Long
Timer1.Enabled = False
If A < 50000 Then
A = A + 1
Text1.Text = CStr(A)
Text1.Refresh
Timer1.Enabled = True
DoEvents
End If

End Sub
_______________________________________



"Jan Raes" <jan.raes@catech.be> wrote in message
news:9kllm9$8q4$1@news.planetinternet.be...
> Hello Per
>
> Thanks for your reply
> DoEvents doesn't really helps as it's still a sequential application
> and not a multitasking one
> Thanks any way
> Jan
>
> "Per Madsen" <per_madsen@pmlotto.dk> wrote in message
> news:3b6c49de$0$31240$ba624c82@nntp01.dk.telia.net...
> >
> > "Jan Raes" <jan.raes@catech.be> wrote in message
> > news:9kdv33$2lc$1@news.planetinternet.be...
> > > Hello,
> > >
> > > I am looking for a solution for this problem :
> > > I have specified an array of forms. Each form contains an algoritm
which
> > > got to live his own life :
> > > they got to run simultanuously and not sequentially. I didn't
succeeded
> > > until now. Help!
> > >
> > > Example :
> > > Create a Form "FrmCounter" with a textbox control "Text1"
> > > and a Commandbutton control "Command1"
> > > Use the following code :
> > >
> > > Private Sub Command1_Click()
> > > Dim A As Long
> > > For A = 1 To 50000
> > > Text1.Text = CStr(A)
> > > Text1.Refresh
> > > Next
> > > End Sub
> > >
> > > Create a module "Start" with the following sub
> > >
> > > Public Sub main()
> > > Dim Frm() As New FrmCounter
> > > Dim C As Integer
> > > ReDim Frm(5)
> > > For C = 1 To NForms
> > > Frm(C).Show
> > > Next C
> > > End Sub
> > >
> > > Define Main() as the startup object.
> > >
> > > When running there are 5 forms displayed on the screen.
> > > When pressing the commandbutton on form 5 the counterloop on form 5
> > > starts counting
> > > While this form is busy counting, you can't start commandbutton on
form
> > > 2 and that's just what I want to do. With other words :
> > > How to share processor time between several open forms without the
need
> > > to create 2 seperate programs : a first, main program which calls
> (shell)
> > > x-times a second, child application.
> > >
> > > Thanks for your help
> > > Regards
> > > Jan
> > >
> > Hello Jan
> > Try to enter a DoEvents like
> >
> > Private Sub Command1_Click()
> > Dim A As Long
> > For A = 1 To 50000
> > Text1.Text = CStr(A)
> > DoEvents 'DoEvents will execute all
> > events pending including
> > 'command button on
form
> 2
> > Text1.Refresh 'You may not need
> Text1.Refresh
> > now....
> > Next
> > End Sub
> >
> >
> >
>
>



Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408929
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste