home *** CD-ROM | disk | FTP | other *** search
- '************************************************
- ' File: EuroRechner.vb
- ' Autor: G. Born www.borncity.de
- '
- ' Umrechnung DM/Euro mittels Formular, Textfeldern und
- ' zwei SchaltflΣchen.
- ' Beim ▄bersetzen die Bibliotheken system.dll,
- ' dll und dll
- ' referenzieren!
- '************************************************
- Option Strict
- Imports System.Drawing
- Imports System.Windows.Forms
- Imports Microsoft.VisualBasic
-
- Class Test
- Shared Eingabe As String ' Eingabespeicher
-
- Shared Sub Main()
- Dim oForm As New Formular() ' Formular anlegen
- oForm.ShowDialog() ' als modalen Dialog anzeigen
- oForm.Dispose()
- End Sub
-
-
- Class Formular ' Formularklasse
- Inherits Form ' wir erben
- Friend WithEvents button As New Button()
- Friend WithEvents button2 As New Button()
- Private label4 As New Label()
- Private label3 As New Label()
- Private textBox2 As New TextBox()
- Private textBox As New TextBox()
- Private label2 As New Label()
- Private label As new Label()
-
-
- Sub New() ' New-Construktor zum Anlegen des Formulars
- MyBase.New() ' Formularobjekt aus Klasse
- With Me
- .Name = "Form"
- .MaximizeBox = false
- .Text = "Euro-Rechner (by G. Born)"
- .Size = New Size(382, 178)
- .FormBorderStyle = FormBorderStyle.Fixed3D
- ' button2
-
-
- button2.Name = "button2"
- button2.TabIndex = 7
- button2.Text = "Schlie▀en"
- button2.Size = New Size(104, 32)
- button2.Location = New Point(160, 80)
- .Controls.Add(button2)
-
- ' button
-
- button.Name = "button"
- button.TabIndex = 6
- button.Text = "Calc"
- button.Size = New Size(112, 32)
- button.Location = New Point(32, 80)
- .Controls.Add(button)
-
- ' label4
- label4 = New Label
- label4.Name = "label4"
- label4.Location = New Point(184, 40)
- label4.Size = New Size(124, 16)
- label4.TabIndex = 5
- label4.Text = "0 DM"
- .Controls.Add(label4)
-
- ' label3
- label3 = New Label
- label3.Name = "label3"
- label3.Location = New Point(184, 8)
- label3.Size = New Size(124, 23)
- label3.TabIndex = 4
- label3.Text = "0 Euro"
- .Controls.Add(label3)
-
- ' textBox2
- textBox2 = New TextBox
- textBox2.Name = "textBox2"
- textBox2.Text = "0"
- textBox2.Size = New Size(96, 20)
- textBox2.Location = New Point(64, 40)
- textBox2.TabIndex = 3
- .Controls.Add(textBox2)
-
- ' textBox
- textBox = New TextBox
- textBox.Name = "textBox"
- textBox.Text = "0"
- textBox.Size = New Size(96, 20)
- textBox.Location = New Point(64, 8)
- textBox.TabIndex = 2
- .Controls.Add(textBox)
-
- ' label2
- label2 = New Label
- label2.Name = "label2"
- label2.Location = New Point(16, 40)
- label2.Size = New Size(48, 24)
- label2.TabIndex = 1
- label2.Text = "Euro"
- .Controls.Add(label2)
-
- ' label
-
- label = New Label
- label.Name = "label"
- label.Location = New Point(16, 8)
- label.Size = New Size(48, 16)
- label.TabIndex = 0
- label.Text = "DM"
- .Controls.Add(label)
- End With
- End Sub
-
- ' Ereignisbehandlungsroutinen
- Private Sub Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
- Me.Close ' Formular schlie▀en
- End Sub
-
- Private Sub Calc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button.Click
- Const EuroFaktor As Double = 1.95583
- Dim tmp As Double
- If IsNumeric (textbox.Text) Then
- tmp = CDbl(textbox.Text) / EuroFaktor ' DM in Euro umrechnen
- label3.Text = tmp.ToString("#,##0.00") & " Euro"
- Else
- label3.Text = "***" ' Fehler
- End If
-
- If IsNumeric (textbox2.Text) Then
- tmp = CDbl(textbox2.Text) * EuroFaktor ' Euro in DM umrechnen
- label4.Text = tmp.ToString("#,##0.00") & " DM"
- Else
- label4.Text = "***" ' Fehler
- End If
- End Sub
- End Class
- End Class