Waiting until loop finished.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • A.G.van Staveren

    #1

    Waiting until loop finished.

    Start learning VB 2005 EE and made a kind of Timing program.
    Tried to show a text during time-call but it comes up only after the loop is
    finished.
    (TextBox2 in Sub Button1_Click)
    I do not understand why.
    Cannot find it either on internet.
    Please can anyone explain to me the reason.
    Here the code so far:
    Public Class Form1

    Dim Uitlezing As Single = 0

    Dim Inlezing As Single = 0

    Dim BeginTime As Double = 0

    Dim FinishTime As Double = 0

    Dim ElapsedTime As Single = 0

    Dim Wachttijd As Single = 5

    Dim Wachttext As String = ""

    Dim TotalTime As Single = 0

    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click



    TextBox2.Text = "Program Runs"

    Call InitializeTimer (Uitlezing, Wachttijd)

    Inlezing = Uitlezing

    Uitlezing = 0

    TextBox1.Text = "Waiting Time was" & " " & Str(Inlezing) & " Seconds."



    End Sub



    Private Sub InitializeTimer (ByRef Uitlezing As Single, ByRef Wachttijd As
    Single)

    ElapsedTime = 0

    BeginTime = Microsoft.Visua lBasic.DateAndT ime.Timer

    Do While ElapsedTime < Wachttijd

    FinishTime = Microsoft.Visua lBasic.DateAndT ime.Timer

    ElapsedTime = (FinishTime - BeginTime)

    Loop

    Uitlezing = ElapsedTime

    End Sub





    Private Sub Wait_Click(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) Handles Wait.Click



    Wachttext = MaskedTextBox1. Text

    Wachttijd = Single.Parse(Wa chttext)

    Call InitializeTimer (Uitlezing, Wachttijd)

    TotalTime = Inlezing + Uitlezing

    TextBox2.Text = "Total Time is" & " " & Str(TotalTime) & " " & "Seconds"


    End Sub


    End Class

    Many thanks,
    Arie


  • Jan Hyde

    #2
    Re: Waiting until loop finished.

    "A.G.van Staveren" <a.vanstaveren1 @chello.nl>'s wild
    thoughts were released on Mon, 5 Feb 2007 16:46:24 +0100
    bearing the following fruit:
    >Start learning VB 2005 EE and made a kind of Timing program.
    This group is for VB6, you need a group with 'dotnet' in the
    name.

    J
    >Tried to show a text during time-call but it comes up only after the loop is
    >finished.
    >(TextBox2 in Sub Button1_Click)
    >I do not understand why.
    >Cannot find it either on internet.
    >Please can anyone explain to me the reason.
    >Here the code so far:
    >Public Class Form1
    >
    >Dim Uitlezing As Single = 0
    >
    >Dim Inlezing As Single = 0
    >
    >Dim BeginTime As Double = 0
    >
    >Dim FinishTime As Double = 0
    >
    >Dim ElapsedTime As Single = 0
    >
    >Dim Wachttijd As Single = 5
    >
    >Dim Wachttext As String = ""
    >
    >Dim TotalTime As Single = 0
    >
    >Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
    >System.EventAr gs) Handles Button1.Click
    >
    >
    >
    >TextBox2.Tex t = "Program Runs"
    >
    >Call InitializeTimer (Uitlezing, Wachttijd)
    >
    >Inlezing = Uitlezing
    >
    >Uitlezing = 0
    >
    >TextBox1.Tex t = "Waiting Time was" & " " & Str(Inlezing) & " Seconds."
    >
    >
    >
    >End Sub
    >
    >
    >
    >Private Sub InitializeTimer (ByRef Uitlezing As Single, ByRef Wachttijd As
    >Single)
    >
    >ElapsedTime = 0
    >
    >BeginTime = Microsoft.Visua lBasic.DateAndT ime.Timer
    >
    >Do While ElapsedTime < Wachttijd
    >
    >FinishTime = Microsoft.Visua lBasic.DateAndT ime.Timer
    >
    >ElapsedTime = (FinishTime - BeginTime)
    >
    >Loop
    >
    >Uitlezing = ElapsedTime
    >
    >End Sub
    >
    >
    >
    >
    >
    >Private Sub Wait_Click(ByVa l sender As System.Object, ByVal e As
    >System.EventAr gs) Handles Wait.Click
    >
    >
    >
    >Wachttext = MaskedTextBox1. Text
    >
    >Wachttijd = Single.Parse(Wa chttext)
    >
    >Call InitializeTimer (Uitlezing, Wachttijd)
    >
    >TotalTime = Inlezing + Uitlezing
    >
    >TextBox2.Tex t = "Total Time is" & " " & Str(TotalTime) & " " & "Seconds"
    >
    >
    >End Sub
    >
    >
    >End Class
    >
    >Many thanks,
    >Arie
    >

    Jan Hyde (VB MVP)

    --
    So I went to the dentist. He said "Say Aaah." I said "Why?" He said "My dog's died."

    Comment

    • Max

      #3
      Re: Waiting until loop finished.

      You would get the same result in VB6 any way

      I can't see anything in the do loop that updates the text box.


      "Jan Hyde" <StellaDrinker@ REMOVE.ME.uboot .comwrote in message
      news:8imes21qhh o64gubui992f0ve ggte0nghg@4ax.c om...
      "A.G.van Staveren" <a.vanstaveren1 @chello.nl>'s wild
      thoughts were released on Mon, 5 Feb 2007 16:46:24 +0100
      bearing the following fruit:
      >
      >>Start learning VB 2005 EE and made a kind of Timing program.
      >
      This group is for VB6, you need a group with 'dotnet' in the
      name.
      >
      J
      >
      >>Tried to show a text during time-call but it comes up only after the loop
      >>is
      >>finished.
      >>(TextBox2 in Sub Button1_Click)
      >>I do not understand why.
      >>Cannot find it either on internet.
      >>Please can anyone explain to me the reason.
      >>Here the code so far:
      >>Public Class Form1
      >>
      >>Dim Uitlezing As Single = 0
      >>
      >>Dim Inlezing As Single = 0
      >>
      >>Dim BeginTime As Double = 0
      >>
      >>Dim FinishTime As Double = 0
      >>
      >>Dim ElapsedTime As Single = 0
      >>
      >>Dim Wachttijd As Single = 5
      >>
      >>Dim Wachttext As String = ""
      >>
      >>Dim TotalTime As Single = 0
      >>
      >>Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
      >>System.EventA rgs) Handles Button1.Click
      >>
      >>
      >>
      >>TextBox2.Te xt = "Program Runs"
      >>
      >>Call InitializeTimer (Uitlezing, Wachttijd)
      >>
      >>Inlezing = Uitlezing
      >>
      >>Uitlezing = 0
      >>
      >>TextBox1.Te xt = "Waiting Time was" & " " & Str(Inlezing) & " Seconds."
      >>
      >>
      >>
      >>End Sub
      >>
      >>
      >>
      >>Private Sub InitializeTimer (ByRef Uitlezing As Single, ByRef Wachttijd As
      >>Single)
      >>
      >>ElapsedTime = 0
      >>
      >>BeginTime = Microsoft.Visua lBasic.DateAndT ime.Timer
      >>
      >>Do While ElapsedTime < Wachttijd
      >>
      >>FinishTime = Microsoft.Visua lBasic.DateAndT ime.Timer
      >>
      >>ElapsedTime = (FinishTime - BeginTime)
      >>
      >>Loop
      >>
      >>Uitlezing = ElapsedTime
      >>
      >>End Sub
      >>
      >>
      >>
      >>
      >>
      >>Private Sub Wait_Click(ByVa l sender As System.Object, ByVal e As
      >>System.EventA rgs) Handles Wait.Click
      >>
      >>
      >>
      >>Wachttext = MaskedTextBox1. Text
      >>
      >>Wachttijd = Single.Parse(Wa chttext)
      >>
      >>Call InitializeTimer (Uitlezing, Wachttijd)
      >>
      >>TotalTime = Inlezing + Uitlezing
      >>
      >>TextBox2.Te xt = "Total Time is" & " " & Str(TotalTime) & " " & "Seconds"
      >>
      >>
      >>End Sub
      >>
      >>
      >>End Class
      >>
      >>Many thanks,
      >>Arie
      >>
      >
      >
      Jan Hyde (VB MVP)
      >
      --
      So I went to the dentist. He said "Say Aaah." I said "Why?" He said "My
      dog's died."
      >

      Comment

      • Jan Hyde

        #4
        Re: Waiting until loop finished.

        "Max" <nospam@spamcat chers.com>'s wild thoughts were
        released on Tue, 6 Feb 2007 22:00:36 +1100 bearing the
        following fruit:
        >You would get the same result in VB6 any way
        That's not necessarily true at all.

        J
        >I can't see anything in the do loop that updates the text box.
        >
        >"Jan Hyde" <StellaDrinker@ REMOVE.ME.uboot .comwrote in message
        >news:8imes21qh ho64gubui992f0v eggte0nghg@4ax. com...
        >"A.G.van Staveren" <a.vanstaveren1 @chello.nl>'s wild
        >thoughts were released on Mon, 5 Feb 2007 16:46:24 +0100
        >bearing the following fruit:
        >>
        >>>Start learning VB 2005 EE and made a kind of Timing program.
        >>
        >This group is for VB6, you need a group with 'dotnet' in the
        >name.
        >>
        >J
        >>
        >>>Tried to show a text during time-call but it comes up only after the loop
        >>>is
        >>>finished.
        >>>(TextBox2 in Sub Button1_Click)
        >>>I do not understand why.
        >>>Cannot find it either on internet.
        >>>Please can anyone explain to me the reason.
        >>>Here the code so far:
        >>>Public Class Form1
        >>>
        >>>Dim Uitlezing As Single = 0
        >>>
        >>>Dim Inlezing As Single = 0
        >>>
        >>>Dim BeginTime As Double = 0
        >>>
        >>>Dim FinishTime As Double = 0
        >>>
        >>>Dim ElapsedTime As Single = 0
        >>>
        >>>Dim Wachttijd As Single = 5
        >>>
        >>>Dim Wachttext As String = ""
        >>>
        >>>Dim TotalTime As Single = 0
        >>>
        >>>Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
        >>>System.Event Args) Handles Button1.Click
        >>>
        >>>
        >>>
        >>>TextBox2.Tex t = "Program Runs"
        >>>
        >>>Call InitializeTimer (Uitlezing, Wachttijd)
        >>>
        >>>Inlezing = Uitlezing
        >>>
        >>>Uitlezing = 0
        >>>
        >>>TextBox1.Tex t = "Waiting Time was" & " " & Str(Inlezing) & " Seconds."
        >>>
        >>>
        >>>
        >>>End Sub
        >>>
        >>>
        >>>
        >>>Private Sub InitializeTimer (ByRef Uitlezing As Single, ByRef Wachttijd As
        >>>Single)
        >>>
        >>>ElapsedTim e = 0
        >>>
        >>>BeginTime = Microsoft.Visua lBasic.DateAndT ime.Timer
        >>>
        >>>Do While ElapsedTime < Wachttijd
        >>>
        >>>FinishTime = Microsoft.Visua lBasic.DateAndT ime.Timer
        >>>
        >>>ElapsedTim e = (FinishTime - BeginTime)
        >>>
        >>>Loop
        >>>
        >>>Uitlezing = ElapsedTime
        >>>
        >>>End Sub
        >>>
        >>>
        >>>
        >>>
        >>>
        >>>Private Sub Wait_Click(ByVa l sender As System.Object, ByVal e As
        >>>System.Event Args) Handles Wait.Click
        >>>
        >>>
        >>>
        >>>Wachttext = MaskedTextBox1. Text
        >>>
        >>>Wachttijd = Single.Parse(Wa chttext)
        >>>
        >>>Call InitializeTimer (Uitlezing, Wachttijd)
        >>>
        >>>TotalTime = Inlezing + Uitlezing
        >>>
        >>>TextBox2.Tex t = "Total Time is" & " " & Str(TotalTime) & " " & "Seconds"
        >>>
        >>>
        >>>End Sub
        >>>
        >>>
        >>>End Class
        >>>
        >>>Many thanks,
        >>>Arie
        >>>
        >>
        >>
        >Jan Hyde (VB MVP)
        >>
        >--
        >So I went to the dentist. He said "Say Aaah." I said "Why?" He said "My
        >dog's died."
        >>
        >

        Jan Hyde (VB MVP)

        --
        "Eating Disorders" by Anna Rexia (Neil Enns)

        Comment

        Working...