CommandButton for further processing

L

leon Galushko

Hi,



I want to set a CommandButton (Click - Event) to let the programm code
(below) progress.

The question is how is that exactly to do on the point.

The as boolean declared variable "PROCEED" is turning "FALSE" after
complieting While Wend - Loop and hereafter is coming the Text on the
TextBox that

can be operated through the User. The User had completed his task and
would have after activating CommandButton to let the programm run
further.

When I have added that code defining the CommandClick - Event to run
further,



Public Sub command1_click()

PROCEED = True

End Sub



It was fruitless!





The programm has to carry on if the user action (Click Event) has turnt
the variable "true", but it doesn't anyway.



What would bet he the right apprroach to it?



Thanks

Leon Galushko





Public Sub form_load()



'declared variables"

....



While End <> True

If IsNumeric(Right(strTemp, 1)) = False Then

Text1 = Text1 + strTemp + " " + vbCrLf + t.ReadLine + " " + vbCrLf

Else: Print #1, strTemp

End If

strTemp = t.ReadLine

str2 = RTrim(strTemp)

proz = Right(str2, 6)

schl1 = (Left(str2, 17) & " " & Right(str2, 6))

schl2 = (Left(str2, 19) & " " & Right(str2, 6))

schl3 = (Left(str2, 18) & " " & Right(str2, 6))

schl4 = (Left(str2, 20) & " " & Right(str2, 6))

If schl1 = schluss1 Or schl2 = schluss2 Or schl3 = schluss3 Or schl4 =
schluss4 Then Ende = True

Wend



Close #1

Ende = False

PROCEED = False


!!! - COMMAND BUTTON CLICK "PROCEED" should take True - Value to make
further



If PROCEDED = True Then



strTemp = t.ReadLine



' weiterer Quellcode....

.............

...........



Public Sub Einlesen_Click()

Open strFile For Append As #1

str0 = Text1 + " " + vbCrLf

Print #1, str0

Close #1

Text1 = ""

End Sub
 
A

Armin Zingler

leon Galushko said:
Hi,



I want to set a CommandButton (Click - Event) to let the programm
code (below) progress.

Have a look at one of the microsoft.public.vb.* group because this is a
VB.Net group.


Armin
 
K

kimiraikkonen

Hi,

I want to set a CommandButton (Click - Event) to let the programm code
(below) progress.

The question is how is that exactly to do on the point.

The as boolean declared variable "PROCEED" is turning "FALSE" after
complieting  While Wend - Loop and hereafter is coming the Text on the
TextBox that

can be operated through the User. The User had completed his task and
would have after activating CommandButton to let the programm run
further.

When I have added that code defining the CommandClick - Event to run
further,

            Public Sub command1_click()

PROCEED = True

End Sub

                                   It was fruitless!

The programm has to carry on if the user action (Click Event) has turnt
the variable "true", but it doesn't anyway.

What would bet he the right apprroach to it?

Thanks

Leon Galushko

Public Sub form_load()

                        'declared variables"

                       ....

While End <> True

If IsNumeric(Right(strTemp, 1)) = False Then

Text1 = Text1 + strTemp + " " + vbCrLf + t.ReadLine + " " + vbCrLf

Else: Print #1, strTemp

End If

strTemp = t.ReadLine

str2 = RTrim(strTemp)

proz = Right(str2, 6)

schl1 = (Left(str2, 17) & " " & Right(str2, 6))

schl2 = (Left(str2, 19) & " " & Right(str2, 6))

schl3 = (Left(str2, 18) & " " & Right(str2, 6))

schl4 = (Left(str2, 20) & " " & Right(str2, 6))

If schl1 = schluss1 Or schl2 = schluss2 Or schl3 = schluss3 Or schl4=
schluss4 Then Ende = True

Wend

Close #1

Ende = False

                                                  PROCEED = False    

!!! - COMMAND BUTTON CLICK "PROCEED" should take True - Value to make
further

If PROCEDED = True Then

This may be a mistype as you wrote "PROCEDED" instead of "PROCEED"
which you probably meant.
strTemp = t.ReadLine

' weiterer Quellcode....

............

..........

Public Sub Einlesen_Click()

Open strFile For Append As #1

str0 = Text1 + " " + vbCrLf

Print #1, str0

Close #1

Text1 = ""

End Sub

your code does not include boolean declaration which must contain as:

Dim PROCEED as Boolean

in declaration area.

Regards.
 
L

leon Galushko

Hi,

The problem seems to be leying on the different Sub Routines.
I had declared in the Reed_Click event section the Boolean variable
"proceed", and in the Main Sub Form_load is the right wording too.
I think indeed the code stops on the point "proceed = False" because
thereby on the Reed_Click Event the value returning should taken place,
it does not carry on to the Main_Sub again, say, its hanging on the
point with the unchanged boolean variable.
I am looking for the approach how could one to let change the value of
the (boolean)variable in the course of the Click_Event.
I mean, Click Event happens and that should lead to the statement
proceed = true, AND THAT in the Main Routine Form_load and not in the
Click_Event Read_Click!
I suppose that task is something of the better level of programming
skills that i am yet lacking, but I would be gratefull just for the
idea!
Regards

Hi,

I want to set a CommandButton (Click - Event) to let the programm code
(below) progress.

The question is how is that exactly to do on the point.

The as boolean declared variable "PROCEED" is turning "FALSE" after
complieting  While Wend - Loop and hereafter is coming the Text on the
TextBox that

can be operated through the User. The User had completed his task and
would have after activating CommandButton to let the programm run
further.

When I have added that code defining the CommandClick - Event to run
further,

            Public Sub command1_click()

PROCEED = True

End Sub

                                   It was fruitless!

The programm has to carry on if the user action (Click Event) has turnt
the variable "true", but it doesn't anyway.

What would bet he the right apprroach to it?

Thanks

Leon Galushko

Public Sub form_load()

                        'declared variables"

                       ....

While End <> True

If IsNumeric(Right(strTemp, 1)) = False Then

Text1 = Text1 + strTemp + " " + vbCrLf + t.ReadLine + " " + vbCrLf

Else: Print #1, strTemp

End If

strTemp = t.ReadLine

str2 = RTrim(strTemp)

proz = Right(str2, 6)

schl1 = (Left(str2, 17) & " " & Right(str2, 6))

schl2 = (Left(str2, 19) & " " & Right(str2, 6))

schl3 = (Left(str2, 18) & " " & Right(str2, 6))

schl4 = (Left(str2, 20) & " " & Right(str2, 6))

If schl1 = schluss1 Or schl2 = schluss2 Or schl3 = schluss3 Or schl4 =
schluss4 Then Ende = True

Wend

Close #1

Ende = False

                                                  PROCEED = False    

!!! - COMMAND BUTTON CLICK "PROCEED" should take True - Value to make
further

If PROCEDED = True Then

This may be a mistype as you wrote "PROCEDED" instead of "PROCEED"
which you probably meant.
strTemp = t.ReadLine

' weiterer Quellcode....

............

..........

Public Sub Read_Click()
Dim proceed as Boolea
Open strFile For Append As #1

str0 = Text1 + " " + vbCrLf

Print #1, str0

Close #1

Text1 = ""


Proceed = true

your code does not include boolean declaration which must contain as:

Dim PROCEED as Boolean

in declaration area.

Regards.
 
L

leon Galushko

Hi,
No, i meant indeed While / Wend Loop, which is not the cause for my
problem.
The Question is, how could I get examined in the form_load section
whether the click event (CommanBox) had taken place. If that was the
case, the boolean variable should "turn true" and so let the code go on.


Public Sub form_load() Dim proceed as boolean
'declared variables"

Proceed = false
While End <> True

.......


If Click_event (command1) = YES then

Proceed = true

If proceed = true then

...further processing.....


Do you mean

While Ende<>True

-or perhaps-

While Not(Ende)

Andrew
 
K

kimiraikkonen

Hi,
No, i meant indeed While / Wend Loop, which is not the cause for my
problem.
The Question is, how could I get examined in the form_load section
whether the click event (CommanBox) had taken place. If that was the
case, the boolean variable should "turn true" and so let the code go on.


Dim proceed as boolean


Proceed = false


......

If Click_event (command1) = YES then

Proceed = true

If proceed = true then

...further processing.....

Do you mean

While Ende<>True

-or perhaps-

While Not(Ende)

Andrew

IIUC from the confusing parts, you may want to display command button
as visible as long as "proceed=true"?
Dim proceed as boolean
While proceed=true
button1.visible = true
End While

here is button1 is your command button and don't forget to hide it by
default till proceed value returns the boolean as true.

Hope this helps.
 
J

Jack Jackson

Hi,
No, i meant indeed While / Wend Loop, which is not the cause for my
problem.
The Question is, how could I get examined in the form_load section
whether the click event (CommanBox) had taken place. If that was the
case, the boolean variable should "turn true" and so let the code go on.




Proceed = false


......


If Click_event (command1) = YES then

Proceed = true

If proceed = true then

...further processing.....


Do you mean

While Ende<>True

-or perhaps-

While Not(Ende)

Andrew

You can not loop in the Load event waiting for the user to press the
button. The Load event code must exit.

Instead put the code you want to execute in a Sub and call it from the
button's Click event.
 
L

leon Galushko

Thank you for your help!

But I might suggest that I had been mistaken.

Once more: click on the CommandButton should produce the change of value
of the given variable(proceed). The question is, how I could get
examined in course of form_load section and NOT in the
CommanButton_Click section, whether the CommandButton had been just
clicked.

Something like that:

Public form_load()

If Command1_Click = True Then
proceed = true

if proceed = true then

...further processing

That is of course a false code, but I intended just to make clear my
purpose.
Thanks
Leon



Hi,
No, i meant indeed While / Wend Loop, which is not the cause for my
problem.
The Question is, how could I get examined in the form_load section
whether the click event (CommanBox) had taken place. If that was the
case, the boolean variable should "turn true" and so let the code go on.

Dim proceed as boolean


Proceed = false


......

If Click_event (command1) = YES then

Proceed = true

If proceed = true then

...further processing.....

Do you mean

While Ende<>True

-or perhaps-

While Not(Ende)

Andrew

IIUC from the confusing parts, you may want to display command button
as visible as long as "proceed=true"?
Dim proceed as boolean
While proceed=true
button1.visible = true
End While

here is button1 is your command button and don't forget to hide it by
default till proceed value returns the boolean as true.

Hope this helps.
 
K

kimiraikkonen

Thank you for your help!

But I might suggest that I had been mistaken.

Once more: click on the CommandButton should produce the change of value
of the given variable(proceed). The question is, how I could get
examined in course of form_load section and NOT in the
CommanButton_Click section, whether the CommandButton had been just
clicked.

Something like that:

Public form_load()

If Command1_Click = True Then
proceed = true

if proceed = true then

...further processing

That is of course a false code, but I intended just to make clear my
purpose.
Thanks
Leon













IIUC from the confusing parts, you may want to display command button
as visible as long as "proceed=true"?
Dim proceed as boolean
While proceed=true
button1.visible = true
End While

here is button1 is your command button and don't forget to hide it by
default till proceed value returns the boolean as true.

Hope this helps.

Seems your code is VB6 one, did you mean that :(.NET version)
you must use button click event to fire a work without assining
boolean value to a button.
Here is a sample which you may need with named button1 (change
command1 name to button1)
'Put this in declaration area before button1_click event
Dim proceed As Boolean
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
proceed = True
While proceed = True
' ' 'do the work
End While

In this strategy you may want to set "proceed" 's initial value as
"false" , because you make it "true" when you click button as follows:

'Put this before button1_click event
Dim proceed as Boolean = false

Hope this helps.
End Sub
 
A

Armin Zingler

leon Galushko said:
Thank you for your help!

But I might suggest that I had been mistaken.

Once more: click on the CommandButton should produce the change of
value of the given variable(proceed). The question is, how I could
get examined in course of form_load section and NOT in the
CommanButton_Click section, whether the CommandButton had been just
clicked.

Something like that:

Public form_load()

If Command1_Click = True Then
proceed = true

if proceed = true then

...further processing

That is of course a false code, but I intended just to make clear my
purpose.


Well, still VB6 code, though...

I failed finding out your intention. The Load event is fired before the Form
is shown. You can not click a Button before the Form is visible. The Button
will *never* have been clicked in the Load event.

Could you please describe the steps that you expect from your application?
When will the user be able to do what?

I *guess* you want to do some processing /and/ you still want to
be able to click a button in order to cancel that process. These are two
things at once. The only clean solution is to use multiple threads. As we
are talking about VB6, well, I remember there was appartment threading in
ActiveX executables, but I think that's really not something to discuss in
this case.

So, please let us know what you're trying to do.


Armin
 
L

leon Galushko

Hi,

now I'll try it again to get presented my problem(on VB6!).
The program is on run and arriving the point in the code where 'proceed'
taken on false - value. The user should make some doings on the TextBox
(not presented here) and when it's ready I want make the User click on
the CommandButton and so let the code run on to the further processing.
To make this I purposed to create a boolean variable named 'proceed'; so
the further running of code should be resumed if the user got activated
the button and could turn to a next processing step because 'proceed' is
now 'true' (see code below) again. Each time command1 is activated the
code have should run further again, BUT that fail! I just have an
impression 'proceed' take the true value again after activating
commanbutton, but that somehow doest not returning on to MainCode there.

Now I will hope had done clear expressions here, only to avoid
misunderstandings!
Regards,
Leon

Public Sub ...()
While End <> True
.................
Wend

Close #1

proceed = False !!! THE CODE IS TO HOLDING HERE

If proceed = True Then !!! HERE should the running code
resume again

strTemp = t.ReadLine

etc, etc



Public Sub command1_Click()
proceed = True
End Sub


-----Ursprüngliche Nachricht-----
Von: Armin Zingler [mailto:[email protected]]
Bereitgestellt: Freitag, 4. Januar 2008 23:21
Bereitgestellt in: microsoft.public.dotnet.languages.vb
Unterhaltung: CommandButton for further processing
Betreff: Re: CommandButton for further processing

leon Galushko said:
Thank you for your help!

But I might suggest that I had been mistaken.

Once more: click on the CommandButton should produce the change of
value of the given variable(proceed). The question is, how I could
get examined in course of form_load section and NOT in the
CommanButton_Click section, whether the CommandButton had been just
clicked.

Something like that:

Public form_load()

If Command1_Click = True Then
proceed = true

if proceed = true then

...further processing

That is of course a false code, but I intended just to make clear my
purpose.


Well, still VB6 code, though...

I failed finding out your intention. The Load event is fired before the
Form
is shown. You can not click a Button before the Form is visible. The
Button
will *never* have been clicked in the Load event.

Could you please describe the steps that you expect from your
application?
When will the user be able to do what?

I *guess* you want to do some processing /and/ you still want to
be able to click a button in order to cancel that process. These are two
things at once. The only clean solution is to use multiple threads. As
we
are talking about VB6, well, I remember there was appartment threading
in
ActiveX executables, but I think that's really not something to discuss
in
this case.

So, please let us know what you're trying to do.


Armin
 
A

Armin Zingler

leon Galushko said:
Hi,

now I'll try it again to get presented my problem(on VB6!).

Why don't you ask in a VB6 group? This is still a VB.Net group. VB is
based on .Net since 2002. VB6 is a different thing, IIRC it's from 1998.

More see below...
The program is on run and arriving the point in the code where
'proceed' taken on false - value. The user should make some doings
on the TextBox (not presented here) and when it's ready I want make
the User click on the CommandButton and so let the code run on to
the further processing. To make this I purposed to create a boolean
variable named 'proceed'; so the further running of code should be
resumed if the user got activated the button and could turn to a
next processing step because 'proceed' is now 'true' (see code
below) again. Each time command1 is activated the code have should
run further again, BUT that fail! I just have an impression
'proceed' take the true value again after activating commanbutton,
but that somehow doest not returning on to MainCode there.

Now I will hope had done clear expressions here, only to avoid
misunderstandings!
Regards,
Leon

Public Sub ...()
While End <> True
................
Wend

Close #1

proceed = False !!! THE CODE IS TO HOLDING HERE

If proceed = True Then !!! HERE should the running code resume again

strTemp = t.ReadLine

etc, etc



Public Sub command1_Click()
proceed = True
End Sub


I really tried to understand the problem, however it's hard for me. What
I see is:
Why don't you put the code after the line "proceed = false" into
command1_click? You want to execute the code as soon as the button is
clicked, right? Then the click event is the right place.

You wrote about "steps" in your application. You can declare a variable
that is incremented each time one step is done. The next time you click
the button, you check the variable and do the step depending on it's
value. For example:

private mNextStep as long = 1

command1_click

select case mNextStep
case 1
'do step 1
case 2
'do step 2
end select

mNextStep = mNextStep + 1

end sub


Armin
 
L

leon Galushko

Sorry,
but it's not the way I will execute the code as soon as the button is
clicked!
Well, try it again! In fact, seems more easy to reflect that seems a bit
puzzling...
Here I post the code it is more real.

Now: the Do While Loop is running anyway, in this MAIN LOOP there are
some more WHILE/WEND - Loops;
Now the TASK is to stop the run temporally after each while/wend and
wait until the user had activated CommandButton to proceed!
To make the code temporally stopping I just thought to include the
Boolean VAR 'proceed'; after each "under-loop" it's turning FALSE to
stop the further processing;

After this Click_Event

Public Sub command1_Click()
Proceed = true
End Sub

'Proceed' is again taken on true and the MainCode should be running
further on to the next "under-loop". The problem is seemingly that the
MainCode does not react on the changing value of 'proceed' after the
Click_Event.
I hope you could give me a hint to manage it!
Thanks,
Leon

Do While t.AtEndOfStream <> True

strTemp = t.ReadLine

If strTemp = b Then

fso.CreateTextFile (strB)


Open strB For Output As #1

While Ende <> True
If IsNumeric(Right(strTemp, 1)) = False Then
Text1 = Text1 + strTemp + " " + vbCrLf + t.ReadLine + " " + vbCrLf
Else: Print #1, strTemp
End If
strTemp = t.ReadLine
str2 = RTrim(strTemp)
proz = Right(str2, 6)
schl1 = (Left(str2, 17) & " " & Right(str2, 6))
schl2 = (Left(str2, 19) & " " & Right(str2, 6))
schl3 = (Left(str2, 18) & " " & Right(str2, 6))
schl4 = (Left(str2, 20) & " " & Right(str2, 6))
If schl1 = schluss1 Or schl2 = schluss2 Or schl3 = schluss3 Or schl4 =
schluss4 Then Ende = True
Wend


Close #1

Ende = False

PROCEED = FALSE

!!!HIER SHOULD TEMPORALY BE STOPPED UNTIL THE USER
ACTIVATE
Command1_Button to carry on

PROCEED = TRUE

strTemp = t.ReadLine

ElseIf strTemp = a Then

fso.CreateTextFile (strA)


Open strA For Output As #1

While Ende <> True

If IsNumeric(Right(strTemp, 1)) = False Then
Text1 = Text1 + strTemp + " " + vbCrLf + t.ReadLine + " " +
vbCrLf
Else: Print #1, strTemp
End If
Print #1, strTemp
strTemp = t.ReadLine
str2 = RTrim(strTemp)
proz = Right(str2, 6)
schl1 = (Left(str2, 17) & " " & Right(str2, 6))
schl2 = (Left(str2, 19) & " " & Right(str2, 6))
schl3 = (Left(str2, 18) & " " & Right(str2, 6))
schl4 = (Left(str2, 20) & " " & Right(str2, 6))
If schl1 = schluss1 Or schl2 = schluss2 Or schl3 = schluss3 Or
schl4 = schluss4 Then Ende = True

Wend

Close #1

Ende = False


PROCEED = FALSE

!!!HIER SHOULD TEMPORALY BE STOPPED UNTIL THE USER
ACTIVATE
CommandButton to carry an

PROCEED = TRUE

Whle Ende <> True

....
---
....
Wend

Close



End If

Loop

t.Close

End Sub




leon Galushko said:
Hi,

now I'll try it again to get presented my problem(on VB6!).

Why don't you ask in a VB6 group? This is still a VB.Net group. VB is
based on .Net since 2002. VB6 is a different thing, IIRC it's from 1998.

More see below...
The program is on run and arriving the point in the code where
'proceed' taken on false - value. The user should make some doings
on the TextBox (not presented here) and when it's ready I want make
the User click on the CommandButton and so let the code run on to
the further processing. To make this I purposed to create a boolean
variable named 'proceed'; so the further running of code should be
resumed if the user got activated the button and could turn to a
next processing step because 'proceed' is now 'true' (see code
below) again. Each time command1 is activated the code have should
run further again, BUT that fail! I just have an impression
'proceed' take the true value again after activating commanbutton,
but that somehow doest not returning on to MainCode there.

Now I will hope had done clear expressions here, only to avoid
misunderstandings!
Regards,
Leon

Public Sub ...()
While End <> True
................
Wend

Close #1

proceed = False !!! THE CODE IS TO HOLDING HERE

If proceed = True Then !!! HERE should the running code resume again

strTemp = t.ReadLine

etc, etc



Public Sub command1_Click()
proceed = True
End Sub


I really tried to understand the problem, however it's hard for me. What
I see is:
Why don't you put the code after the line "proceed = false" into
command1_click? You want to execute the code as soon as the button is
clicked, right? Then the click event is the right place.

You wrote about "steps" in your application. You can declare a variable
that is incremented each time one step is done. The next time you click
the button, you check the variable and do the step depending on it's
value. For example:

private mNextStep as long = 1

command1_click

select case mNextStep
case 1
'do step 1
case 2
'do step 2
end select

mNextStep = mNextStep + 1

end sub


Armin
 
A

Armin Zingler

leon Galushko said:
Sorry,
but it's not the way I will execute the code as soon as the button
is clicked!
Well, try it again! In fact, seems more easy to reflect that seems a
bit puzzling...
Here I post the code it is more real.

Now: the Do While Loop is running anyway, in this MAIN LOOP there
are some more WHILE/WEND - Loops;
Now the TASK is to stop the run temporally after each while/wend and
wait until the user had activated CommandButton to proceed!
To make the code temporally stopping I just thought to include the
Boolean VAR 'proceed'; after each "under-loop" it's turning FALSE to
stop the further processing;


I've looked at the code, but what I see is that the code is to continue
when the button is clicked. In your first sentence above you write, this
is not true. That's why I don't understand the problem.

Maybe I can help better if you reduce the code to few lines that show
the problem and which I can copy and execute here. Your code is not
executable here. Hint: Before pasting code in the posting, insert it in
notepad and copy it again from there because, otherwise, line indention
gets lost and it's hard to read.

Ok, if anybody is interested - still VB6 - I created a formatted and
compilable (not executable!) version:
(Reference to "Microsoft Scripting runtime" required)

More see below the code.


Sub test()

Dim fso As New FileSystemObject
Dim t As TextStream
Dim strTemp As String
Dim b As String
Dim strb As String
Dim Ende As Boolean
Dim Text1 As String
Dim str2 As String
Dim proz As String
Dim schl1 As String
Dim schl2 As String
Dim schl3 As String
Dim schl4 As String
Dim schluss1 As String
Dim schluss2 As String
Dim schluss3 As String
Dim schluss4 As String
Dim a As String
Dim stra As String

Dim proceed As Boolean


Set t = fso.CreateTextFile("")

Do While t.AtEndOfStream <> True

strTemp = t.ReadLine

If strTemp = b Then
fso.CreateTextFile (strb)

Open strb For Output As #1

While Ende <> True
If IsNumeric(Right(strTemp, 1)) = False Then
Text1 = Text1 + strTemp + " " + vbCrLf _
+ t.ReadLine + " " + vbCrLf
Else
Print #1, strTemp
End If

strTemp = t.ReadLine
str2 = RTrim(strTemp)
proz = Right(str2, 6)
schl1 = (Left(str2, 17) & " " & Right(str2, 6))
schl2 = (Left(str2, 19) & " " & Right(str2, 6))
schl3 = (Left(str2, 18) & " " & Right(str2, 6))
schl4 = (Left(str2, 20) & " " & Right(str2, 6))

If schl1 = schluss1 Or schl2 = schluss2 Or _
schl3 = schluss3 Or schl4 = schluss4 Then Ende = True
Wend


Close #1

Ende = False

proceed = False

'!!!HIER SHOULD TEMPORALY BE STOPPED UNTIL THE
'USER ACTIVATE Command1_Button to carry on

proceed = True

strTemp = t.ReadLine

ElseIf strTemp = a Then

fso.CreateTextFile (stra)


Open stra For Output As #1

While Ende <> True

If IsNumeric(Right(strTemp, 1)) = False Then
Text1 = Text1 + strTemp + " " + vbCrLf _
+ t.ReadLine + " " + vbCrLf
Else
Print #1, strTemp
End If

Print #1, strTemp
strTemp = t.ReadLine
str2 = RTrim(strTemp)
proz = Right(str2, 6)
schl1 = (Left(str2, 17) & " " & Right(str2, 6))
schl2 = (Left(str2, 19) & " " & Right(str2, 6))
schl3 = (Left(str2, 18) & " " & Right(str2, 6))
schl4 = (Left(str2, 20) & " " & Right(str2, 6))
If schl1 = schluss1 Or schl2 = schluss2 _
Or schl3 = schluss3 Or schl4 = schluss4 Then Ende = True

Wend

Close #1

Ende = False


proceed = False

'!!!HIER SHOULD TEMPORALY BE STOPPED UNTIL
'THE USER ACTIVATE CommandButton to carry an

proceed = True

While Ende <> True

'...
'---
'...
Wend

Close

End If

Loop

t.Close

End Sub



After narrowing the problem down, this is the basic structure:

Sub TestSimplified()

Dim Cond1 As Boolean
Dim Cond2 As Boolean
Dim Cond3 As Boolean

Do While Cond1
If Cond2 Then
'Code
'Wait for Button click
'Code
ElseIf Cond3 Then
'Code
'Wait for Button click
'Code
End If
Loop

End Sub


Or even simpler: (pseudo code)

Sub TestSimplified2()

Do
'Wait for Button click
Loop

End Sub




Now I see the problem: You are inside a loop and the execution should
stop inside the loop until the button is pressed.

There are two solutions:

- Declare the required variables outside the sub in order to be able to
continue the execution of the code when the button is clicked the next
time. This requires the redesign of your code that I am not able to
perform here. I can only give a general approach: Instead of waiting for
a click inside a loop, do the work inside the button's click event.
Store all required information at module level in order to be able to
continue the execution when the button is clicked the next time.

- Use multiple threads. As you're still using VB6, I can not give an
advice.




Here is an example of what I meant with the first solution:

Before, you have:

Sub before()

Dim dnr As Integer

dnr = FreeFile

Open "g:\test.txt" For Input As dnr

Do Until EOF(dnr)
Dim Zeile As String
Line Input #dnr, Zeile
Debug.Print Zeile
'**** wait for click ****
Loop

Close #dnr

End Sub



After the redesign:

Dim dnr As Integer

Sub Start()

dnr = FreeFile

Open "g:\test.txt" For Input As dnr
OneStep

End Sub
Private Sub OneStep()

Dim Zeile As String

If EOF(dnr) Then
Close #dnr
dnr = 0
Else
Line Input #dnr, Zeile
Debug.Print Zeile
End If

End Sub

Private Sub Command1_Click()

If dnr = 0 Then
Start
Else
OneStep
End If

End Sub




Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top