VERSION 5.00 Begin VB.Form FormTypes Caption = "zelfgedefinieerde types - zie source code - " ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 7530 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 7530 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmdTune BackColor = &H00FF8080& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Index = 0 Left = 120 TabIndex = 2 ToolTipText = "click here to here the tone and tune your guitar" Top = 2400 Width = 975 End Begin VB.CommandButton cmdExit Caption = "Exit" Height = 495 Left = 6240 TabIndex = 1 Top = 120 Width = 1215 End Begin VB.Label lblFeedback BackColor = &H00000000& BorderStyle = 1 'Fixed Single BeginProperty Font Name = "MS Sans Serif" Size = 13.5 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H0000FF00& Height = 1815 Left = 240 MousePointer = 3 'I-Beam TabIndex = 0 Top = 120 Width = 5175 WordWrap = -1 'True End End Attribute VB_Name = "FormTypes" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False ' Koen Noens ' oefening : zelfgedefinieerde gegevenstypes ' ' >>> Koen's Guitar Tuner <<< Option Explicit 'voorbeeld van 'Type' Private Type GitaarSnaar Naam As String * 7 Freq As Long End Type Dim RecordLengte As Integer 'Array van 6 GitaarSnaren Dim Snaar(5) As GitaarSnaar 'systeem functie Beep Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long Private Sub cmdTune_Click(Index As Integer) Dim strMsg As String 'output feedback strMsg = "Now playing string " & Snaar(Index).Naam & vbCrLf _ & "Frequency = " & Snaar(Index).Freq & " Hertz." lblFeedback.Caption = strMsg 'play tone Beep Snaar(Index).Freq, 500 End Sub Private Sub Form_Load() Init LoadButtons End Sub Private Sub Init() Dim i As Integer 'lengte van een record (samengestelde variabele - TYPE-) 'verder nergens voor nodig in dit programma ... RecordLengte = Len(Snaar(1)) 'assignment voor defined type Snaar(0).Naam = "E (Mi)" Snaar(0).Freq = 330 Snaar(1).Naam = "A (La)" Snaar(1).Freq = 440 Snaar(2).Naam = "D (Re)" Snaar(2).Freq = 588 Snaar(3).Naam = "G (Sol)" Snaar(3).Freq = 785 Snaar(4).Naam = "B (Si)" Snaar(4).Freq = 990 Snaar(5).Naam = "E (Mi)" Snaar(5).Freq = 1320 End Sub Private Sub LoadButtons() Dim i As Integer With cmdTune(0) .Caption = Snaar(0).Naam .Width = (FormTypes.Width / 6) - 100 .Enabled = True .Visible = True End With For i = 1 To 5 Load cmdTune(i) With cmdTune(i) .Caption = Snaar(i).Naam .Left = cmdTune(i - 1).Left + cmdTune(i).Width + 50 .Enabled = True .Visible = True End With Next i End Sub Private Sub cmdExit_Click() 'unload form, exit program Unload Me End Sub