Hoi,
ik probeer een programma te schrijven in VB, voor school, waarmee ik muntsoorten om kan rekenen.
Het programma bestaat uit een tekstbox, een combobox, daaronder een button en daaronder nog een tekstbox.
In de bovenste tekstbox voer je het aantal in van de munt. In de list kies je de muntsoort:
Code:
Amerika - Dollar > Euro
Australië - Dollar > Euro
Brazilië - Real > Euro
Canada - Dollar > Euro
Cyprus - Pond > Euro
Egypte - Pond > Euro
Groot Brittanië - Pond > Euro
Hongkong - Dollar > Euro
Japan - Yen > Euro
Marokko - Dirham > Euro
Noord-Ierland - Pond > Euro
Schotland - Pond > Euro
Turkije - Lira > Euro
Zuid-Afrika - Rand > Euro
Zwitserland - Frank > Euro
Euro > Amerika - Dollar
Euro > Australië - Dollar
Euro > Brazilië - Real
Euro > Canada - Euro
Euro > Cyprus - Pond
Euro > Egypte - Pond
Euro > Groot Brittanië - Pond
Euro > Hongkong - Dollar
Euro > Japan - Yen
Euro > Marokko - Dirham
Euro > Noord-Ierland - Pond
Euro > Schotland - Pond
Euro > Turkijke - Lira
Euro > Zuid-Afrika - Rand
Euro > Zwitserland - Frank
Dit is de code die ik tot nu toe heb ingevoerd:
Code:
Private Sub cmdBereken_Click()
'leest muntaantal1 uit txtInvoer
'rekent muntaantal1 om naar muntaantal2
'schrijft muntaantal2 in txtUitvoer
'declaraties
Dim txtInvoer As Double
Dim muntwaarde As Double
Dim txtUitvoer As Double
'hoofdprogramma
If cmbMuntSoort.DataField = "Amerika - Dollar > Euro" Then muntwaarde = 0.8084 * muntaantal1
txtInvoer = Val(txtInvoer.Text)
txtUitvoer = txtInvoer * cmbMuntSoort.List
txtUitvoer.Text = Str(muntaantal2)
End Sub
Zoals jullie zien klopt hij niet, maar weet iemand hoe ik dit wel doe? Ik moet dus ook nog waardes toekennen aan die list, hoe doe ik dit?
En hoe zeg ik dan dat hij dat moet berekenen uit wat er in die list staat?
De bovenste tekstbox heeft txtInvoer, de list heet cmbMuntSoort, de button cmdBereken en de onderste tekstbox (waar de uitkomst in zou moeten staan) heet txtUitvoer.
Alsvast bedankt, want ik kom zo niet verder.