Ich habe die eingabe auf Zahlen beschränkt.
Wenn ich jetzt Kommas mache kann ich die nur mit . machen und nicht mit , und die Punkte ingnoriert der dann. Ach ich zeige einfach mal das Prob
Public Class MainForm Inherits System.Windows.Forms.Form Private Const DM As Decimal = 1.95583D ' Deutsche Mark Private Const BEF As Decimal = 40.3399D ' Belgische Francs Private Const ATS As Decimal = 13.7603D ' Österreichische Schilling Private Const FRF As Decimal = 6.55957D ' Französische Francs Private Sub txtBetrag_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtBetrag.KeyPress Select Case AscW(e.KeyChar) Case 46, 48 To 57, 8 ' Dezimalkomma, Ziffern und Backspace zulassen Case Else MsgBox("Wie soll man etwas anderes als Zahlen Umrechen ?") e.Handled = True End Select End Sub Private Sub btnUmrechnen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUmrechnen.Click Dim Betrag As Decimal = CDec(txtBetrag.Text) Dim Ergebnis As Decimal Select Case cmbFrom.SelectedItem Case cmbFrom.Items.Item(1) ' DM in Euro umrechnen Ergebnis = Math.Round(Betrag / DM, 2) lblErgebnis.Text = txtBetrag.Text & " DM sind " & _ "umgerechnet " & Ergebnis.ToString() & " Euro." Case cmbFrom.Items.Item(2) ' Belgische Francs in Euro umrechnen Ergebnis = Math.Round(Betrag / BEF, 2) lblErgebnis.Text = txtBetrag.Text & " BEF sind " & _ "umgerechnet " & Ergebnis.ToString() & " Euro." Case cmbFrom.Items.Item(3) ' Französische Francs in Euro umrechnen Ergebnis = Math.Round(Betrag / FRF, 2) lblErgebnis.Text = txtBetrag.Text & " FRF sind " & _ "umgerechnet " & Ergebnis.ToString() & " Euro." Case cmbFrom.Items.Item(4) ' Österreichische Schilling in Euro umrechnen Ergebnis = Math.Round(Betrag / ATS, 2) lblErgebnis.Text = txtBetrag.Text & " ATS sind " & _ "umgerechnet " & Ergebnis.ToString() & " Euro." End Select End Sub End Class
Ich hoffe dadurch ist es klarer