【问题标题】:how to terminate the execution of a loop when a key is press?按下键时如何终止循环的执行?
【发布时间】:2018-06-26 08:26:53
【问题描述】:

我有一个场景,我一个一个地显示集合的内容,直到按下一个键。问题是我无法获得正确的代码来确定何时按下某个键。我正在使用 VB.net 语言在 Visual Studio Lightswitch 中进行设计。下面的链接显示了我的程序的输出。 Sample output of the program。显示一直循环,直到用户按下一个键。下面也是我正在使用的示例代码。

    Private Sub Compliances_Activated()
        ' Write your code here.
       Do until "***the problem is here, I suppose to handle keyevents here but with no luck."***
            For Each I In Me.PendingCompliance
                If I.Incharge = "S1" Then
                    Me.Partic = I.Particulars
                    Me.ActionToUndertake = I.ActionToUndertake
                    Me.StatusOfCompliance = I.StatusOfCompliance
                    Dim controlcurr1 = Me.FindControl("Partic1")
                    AddHandler controlcurr1.ControlAvailable, _
                        Sub(sender As Object, e As ControlAvailableEventArgs)
                            Dim textbox = CType(e.Control, System.Windows.Controls.TextBlock)
                            textbox.Foreground = New SolidColorBrush(Color.FromArgb(200, 0, 126, 230))
                            textbox.Height = (400.0)
                            textbox.FontSize = Convert.ToDouble(72.0)
                            textbox.FontFamily = New FontFamily("arial")
                            textbox.TextTrimming = TextTrimming.None

                        End Sub

                    Dim newsText1 = Me.FindControl("Partic1")
                    AddHandler newsText1.ControlAvailable, Sub(sender, e)

                                                               'Get the istance
                                                               Dim block = CType(e.Control, TextBlock)

                                                               'Set a different color, if you like
                                                               block.Foreground = New SolidColorBrush(Colors.Black)

                                                               'Create an animation
                                                               Dim sb As New Storyboard
                                                               Dim colorAnim As New ColorAnimation
                                                               colorAnim.AutoReverse = True
                                                               colorAnim.RepeatBehavior = RepeatBehavior.Forever
                                                               colorAnim.From = Colors.Blue
                                                               colorAnim.To = Colors.White
                                                               colorAnim.Duration = TimeSpan.FromSeconds(8)

                                                               'Apply the animation
                                                               Storyboard.SetTarget(colorAnim, block.Foreground)
                                                               Storyboard.SetTargetProperty(colorAnim, New PropertyPath("Color"))
                                                               sb.Children.Add(colorAnim)
                                                               sb.Begin()

                                                           End Sub

如果结束 下一个 请帮忙

【问题讨论】:

    标签: visual-studio-lightswitch


    【解决方案1】:

    你用的是什么?

    大概是这样的

    String answer;
    If(answer!=" ")
    
    break;
    

    【讨论】:

    • 我在visual studio lightswitch 中使用VB.net。有一个 VSLS 论坛,但似乎已经不活跃,这就是我来这里寻求帮助的原因。
    猜你喜欢
    • 1970-01-01
    • 2016-10-06
    • 2017-05-23
    • 1970-01-01
    • 2020-06-29
    • 2022-11-21
    • 1970-01-01
    • 2012-07-14
    • 2014-08-17
    相关资源
    最近更新 更多