Visual Basic Tutorialreihe – extra 2 – Tastenkürzel

In diesem Video zeige ich euch, wie ihr in Visual Basic Tastatureingaben abfragt und Tastenkürzel erstellt.

Quellcode

Public Class Form1

Dim isStrgDown As Boolean = False

Private Sub Form1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp

Select Case e.KeyCode
Case Windows.Forms.Keys.A
If isStrgDown Then
MessageBox.Show(„A“)
isStrgDown = False
End If
Case Windows.Forms.Keys.ControlKey
isStrgDown = False
End Select

End Sub

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Windows.Forms.Keys.ControlKey Then
isStrgDown = True
End If
End Sub
End Class

Visual Basic Tutorialreihe – extra 1 – Mikrophone aufnehmen

In diesem extra meiner Visual Basic Tutorialreihe  zeige ich euch, wie ihr ein Mikrophon mit mciSendStrind aufnehmt.

Quellcode:

Public Class Form1

    Private Declare Function mciSendString Lib „winmm.dll“ Alias „mciSendStringA“ (ByVal Command As String, ByVal ReturnString As String, ByVal ReturnLenght As Integer, ByVal Callback As Integer) As Integer

    Dim Path As String = „C:\Users\Manuel\Desktop\Test.wav“
    Dim rs As String
    Dim cb As String

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If Button1.Text = „Record“ Then
            Button1.Text = „Stop“
            Button2.Enabled = False
            rs = New String(“ „, 128)
            mciSendString(„Open New Type waveaudio Alias aufnahme“, rs, 128, cb)
            mciSendString(„record aufnahme“, rs, 128, cb)
        Else
            Button1.Text = „Record“
            Button2.Enabled = True
            mciSendString(„Stop aufnahme“, rs, 128, cb)
            mciSendString(„save aufnahme “ & Path, rs, 128, cb)
            mciSendString(„Close aufnahme“, rs, 128, cb)
        End If
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        My.Computer.Audio.Play(Path, AudioPlayMode.Background)
    End Sub
End Class