Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[VB 2008] Timer per Tastendruck

Empfohlene Antworten

Veröffentlicht

Tach,

Ich hab mal wieder ein Problem und zwar möchte ich mein Panel bewegen, wobei ich den Timer per Tastendruck starte, der dann mein Panel bewegt.

Nur weiss ich nicht wie ich den Timer abschalte sobald ich die Taste loslasse :(

Hier mal der Code:


Public Class Form1


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        timRunter.Enabled = False

        timRechts.Enabled = False

        timOben.Enabled = False

        timLinks.Enabled = False

    End Sub


    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown


        If e.KeyCode = Keys.Up Then

            timRunter.Enabled = False

            timRechts.Enabled = False

            timOben.Enabled = True

            timLinks.Enabled = False


        ElseIf e.KeyCode = Keys.Down Then

            timRunter.Enabled = True

            timRechts.Enabled = False

            timOben.Enabled = False

            timLinks.Enabled = False


        ElseIf e.KeyCode = Keys.Right Then

            timRunter.Enabled = False

            timRechts.Enabled = True

            timOben.Enabled = False

            timLinks.Enabled = False


        ElseIf e.KeyCode = Keys.Left Then

            timRunter.Enabled = False

            timRechts.Enabled = False

            timOben.Enabled = False

            timLinks.Enabled = True

        End If


    End Sub


    Private Sub timRunter_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timRunter.Tick

        panFigur.Location = New Point( _

        panFigur.Location.X, _

        panFigur.Location.Y + 2)

    End Sub


    Private Sub timRechts_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timRechts.Tick

        panFigur.Location = New Point( _

                panFigur.Location.X + 2, _

                panFigur.Location.Y)

    End Sub


    Private Sub timOben_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timOben.Tick

        panFigur.Location = New Point( _

        panFigur.Location.X, _

        panFigur.Location.Y - 2)

    End Sub


    Private Sub timLinks_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timLinks.Tick

        panFigur.Location = New Point( _

        panFigur.Location.X - 2, _

        panFigur.Location.Y)

    End Sub


End Class

Mfg Cartman

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown


        If e.KeyCode = Keys.Up Then

            timRunter.Enabled = False

            timRechts.Enabled = False

            timOben.Enabled = True

            timLinks.Enabled = False


        ElseIf e.KeyCode = Keys.Down Then

            timRunter.Enabled = True

            timRechts.Enabled = False

            timOben.Enabled = False

            timLinks.Enabled = False


        ElseIf e.KeyCode = Keys.Right Then

            timRunter.Enabled = False

            timRechts.Enabled = True

            timOben.Enabled = False

            timLinks.Enabled = False


        ElseIf e.KeyCode = Keys.Left Then

            timRunter.Enabled = False

            timRechts.Enabled = False

            timOben.Enabled = False

            timLinks.Enabled = True

        End If


    End Sub

Es gibt nicht nur KeyDown, sondern auch KeyUp :)

Ouh Man D:

Danke! ^^

& noch ne Frage,

Wie löse ich etwas aus wenn mein Panel jetzt ein anderes berührt?

z.B. Ich streife mit meinem panFigur, ein anders festes Panel & dann soll eine MsgBox auftauchen

Mit If panFigur.location = <anders panel>, bla bla bla

geht's schonmal nicht :|

Evtl. so?


Dim recFest As New Rectangle(panelFest.Location.X, panelFest.Location.Y, panelFest.Size.Width, panelFest.Size.Height)


Dim recFigur As New Rectangle(panelFigur.Location.X, panelFigur.Location.Y, panelFigur.Size.Width, panelFigur.Size.Height)


If recFest.IntersectsWith(recFigur) Then

 Bla

End If

Danke :)

Das klappt auch alles ganz gut, nur kommt die Meldung erst nachdem ich komplett durch das andere Panel durchgefahren bin, jedenfalls sehr verspätet ^^

Gibt es auch Möglichkeit den Bereich auf dem das Panel sich bewegen kann auch einzuschränken?

Also nur nicht nur in nem Viereck sondern z.B. in nem Labyrinth :D

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.