Leren programmeren: vervoegingen


In dit programma willen we een regelmatig Frans werkwoord op –ER vervoegen. We voorzien een tekstvak om de stam van het werkwoord in te tikken, drie aankruisvakken om de tijd te kiezen (présent, imparfait, passé composé). In functie van het geselecteerde aankruisvak bouwen we de vervoeging op van de gekozen tijd.

De code ziet er dan zo uit:

Private Sub cmdVervoeg_Click()
Dim stam As String
stam = txtStam.Text
If optPresent.Value = True Then
  lblVervoeging.Caption = "je " & stam & "e" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "tu " & stam & "es" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "il " & stam & "e" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "nous " & stam & "ons" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "vous " & stam & "ez" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "ils " & stam & "ent"

End If

If optImparfait.Value = True Then
  lblVervoeging.Caption = "je " & stam & "ais" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "tu " & stam & "ais" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "il " & stam & "ait" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "nous " & stam & "ions" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "vous " & stam & "iez" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "ils " & stam & "aient"

End If

If optPasséComposé.Value = True Then
  lblVervoeging.Caption = "j'ai " & stam & "é" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "tu as " & stam & "é" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "il a " & stam & "é" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "nous avons " & stam & "é" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "vous avez " & stam & "é" & vbCrLf
  lblVervoeging.Caption = lblVervoeging.Caption & "ils ont " & stam & "é"
End If

End Sub

Enkele bemerkingen:


[VB Web] - [Leren programmeren] - [hlrnet] - [copyright]